use std::{future::Future, pin::Pin, task::Poll, sync::Arc}; use keyfork_mnemonic_util::Mnemonic; use minicbor::{Decode, Encode}; use tower::Service; use thiserror::Error; #[derive(Encode, Decode, Clone, Debug)] pub struct DerivablePath { #[n(0)] path: Vec>, } // TODO: move DerivablePath into a models crate for clients to produce? /* impl DerivablePath { pub fn new(input: &[&[u8]]) -> DerivablePath { DerivablePath { path: input .iter() .map(|&word| { // perform path validation word.to_vec() }) .collect(), } } } */ #[derive(Clone, Debug)] pub struct Keyforkd { mnemonic: Arc, } // Currently, this can't be instantiated, therefore it is a never-type #[derive(Debug, Error)] pub enum DerivationError { } impl Keyforkd { pub fn new(mnemonic: Mnemonic) -> Self { Self { mnemonic: Arc::new(mnemonic) } } } impl Service for Keyforkd { type Response = Vec; type Error = DerivationError; type Future = Pin> + Send>>; fn poll_ready( &mut self, _cx: &mut std::task::Context<'_>, ) -> std::task::Poll> { Poll::Ready(Ok(())) } #[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))] fn call(&mut self, req: DerivablePath) -> Self::Future { dbg!(&req, &self.mnemonic); Box::pin(async { Ok(vec![]) }) } }