keyfork-seed: make bin into lib with bin

This commit is contained in:
Ryan Heywood 2023-09-11 23:21:19 -05:00
parent 2e9bfde9b4
commit fe8b901bd3
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
2 changed files with 39 additions and 35 deletions

37
keyfork-seed/src/lib.rs Normal file
View File

@ -0,0 +1,37 @@
use std::path::PathBuf;
use keyfork_frame::{EncodeError, DecodeError};
pub mod cli;
pub mod socket;
pub mod client;
pub use client::Client;
#[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<bincode::ErrorKind>),
#[error("Could not perform frame transformation: {0}")]
FrameEnc(#[from] EncodeError),
#[error("Could not perform frame transformation: {0}")]
FrameDec(#[from] DecodeError),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;

View File

@ -1,42 +1,9 @@
use keyfork_derive_util::{request::*, DerivationPath}; use keyfork_derive_util::{request::{DerivationRequest, DerivationAlgorithm}, DerivationPath};
use keyfork_frame::*;
use std::path::PathBuf;
mod cli;
mod socket;
mod client;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
#[derive(Debug, thiserror::Error)] use keyfork_seed::*;
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<bincode::ErrorKind>),
#[error("Could not perform frame transformation: {0}")]
FrameEnc(#[from] EncodeError),
#[error("Could not perform frame transformation: {0}")]
FrameDec(#[from] DecodeError),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
fn main() -> Result<()> { fn main() -> Result<()> {
let args = cli::get_args(); let args = cli::get_args();