use std::{future::Future, pin::Pin, sync::Arc, task::Poll}; use keyfork_derive_util::DerivablePath; use keyfork_mnemonic_util::Mnemonic; use thiserror::Error; use tower::Service; #[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![]) }) } }