feat: v0.1.2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "external-command-rs"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2024"
|
||||
authors = ["Hatter Jiang"]
|
||||
repository = "https://git.hatter.ink/hatter/external-command-rs"
|
||||
|
||||
36
src/lib.rs
36
src/lib.rs
@@ -1,7 +1,7 @@
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use base64::Engine;
|
||||
use rust_util::{debugging, opt_result, simple_error, XResult};
|
||||
use serde::{de, Deserialize, Serialize};
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use rust_util::{XResult, debugging, opt_result, simple_error};
|
||||
use serde::{Deserialize, Serialize, de};
|
||||
use serde_json::Value;
|
||||
use std::process::{Command, Output};
|
||||
|
||||
@@ -37,6 +37,36 @@ struct ExternalDhResult {
|
||||
pub shared_secret_hex: String,
|
||||
}
|
||||
|
||||
pub struct ExternalCommand {
|
||||
pub external_command: String,
|
||||
pub parameter: String,
|
||||
}
|
||||
|
||||
impl ExternalCommand {
|
||||
pub fn new(external_command: String, parameter: String) -> ExternalCommand {
|
||||
ExternalCommand {
|
||||
external_command,
|
||||
parameter,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spec(&self) -> XResult<ExternalSpecResult> {
|
||||
external_spec(&self.external_command)
|
||||
}
|
||||
|
||||
pub fn public_key(&self) -> XResult<Vec<u8>> {
|
||||
external_public_key(&self.external_command, &self.parameter)
|
||||
}
|
||||
|
||||
pub fn sign(&self, alg: &str, content: &[u8]) -> XResult<Vec<u8>> {
|
||||
external_sign(&self.external_command, &self.parameter, alg, content)
|
||||
}
|
||||
|
||||
pub fn ecdh(&self, ephemera_public_key: &[u8]) -> XResult<Vec<u8>> {
|
||||
external_ecdh(&self.external_command, &self.parameter, ephemera_public_key)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn external_spec(external_command: &str) -> XResult<ExternalSpecResult> {
|
||||
let mut cmd = Command::new(external_command);
|
||||
cmd.arg("external_spec");
|
||||
|
||||
Reference in New Issue
Block a user