jsonrpc_ipc_server/
meta.rsuse std::path::Path;
use crate::jsonrpc::futures::channel::mpsc;
use crate::jsonrpc::Metadata;
use crate::server_utils::session;
pub struct RequestContext<'a> {
pub session_id: session::SessionId,
pub endpoint_addr: &'a Path,
pub sender: mpsc::UnboundedSender<String>,
}
pub trait MetaExtractor<M: Metadata>: Send + Sync + 'static {
fn extract(&self, context: &RequestContext) -> M;
}
impl<M, F> MetaExtractor<M> for F
where
M: Metadata,
F: Fn(&RequestContext) -> M + Send + Sync + 'static,
{
fn extract(&self, context: &RequestContext) -> M {
(*self)(context)
}
}
pub struct NoopExtractor;
impl<M: Metadata + Default> MetaExtractor<M> for NoopExtractor {
fn extract(&self, _context: &RequestContext) -> M {
M::default()
}
}