use keyfork_derive_util::{request::*, DerivationPath}; use keyfork_frame::*; use std::path::PathBuf; mod cli; mod socket; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("The first argument to the command should be a derivation path")] Args, #[error("The given path was incorrectly formatted: {0}")] ArgsFormat(#[from] keyfork_derive_util::path::Error), #[error("Neither KEYFORK_SOCKET_PATH nor XDG_RUNTIME_DIR were set")] EnvVarsNotFound, #[error("Socket was unable to connect to {1}: {0}")] Connect(std::io::Error, PathBuf), #[error("Could not write to or from the socket: {0}")] Io(#[from] std::io::Error), #[error("Could not perform bincode transformation: {0}")] Bincode(#[from] Box), #[error("Could not perform frame transformation: {0}")] FrameEnc(#[from] EncodeError), #[error("Could not perform frame transformation: {0}")] FrameDec(#[from] DecodeError), } fn main() -> Result<(), Error> { let args = cli::get_args(); let mut socket = socket::get_socket()?; let path = args.get_one::("path").expect("required"); let algo = args .get_one::("algorithm") .expect("required"); let req = DerivationRequest::new(algo.clone(), path.clone()); let ser_req = bincode::serialize(&req)?; try_encode_to(&ser_req, &mut socket)?; let ser_response = try_decode_from(&mut socket)?; let response: DerivationResponse = bincode::deserialize(&ser_response)?; dbg!(&response); Ok(()) }