pub struct FunctionHandler<F, N, E>where
E: Error + Send + Sync + 'static,
F: Fn(&str, Option<RequestParams>, Option<SessionContext>) -> BoxFuture<'static, Result<Value, E>> + Send + Sync,
N: Fn(&str, Option<RequestParams>, Option<SessionContext>) -> BoxFuture<'static, Result<(), E>> + Send + Sync,{ /* private fields */ }
Expand description
A simple function-based handler
Implementations§
Source§impl<F, N, E> FunctionHandler<F, N, E>
impl<F, N, E> FunctionHandler<F, N, E>
pub fn new(handler_fn: F) -> Self
pub fn with_notification_handler(self, notification_fn: N) -> Self
pub fn with_methods(self, methods: Vec<String>) -> Self
Trait Implementations§
Source§impl<F, N, E> JsonRpcHandler for FunctionHandler<F, N, E>
impl<F, N, E> JsonRpcHandler for FunctionHandler<F, N, E>
Source§fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Option<RequestParams>,
session_context: Option<SessionContext>,
) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Option<RequestParams>,
session_context: Option<SessionContext>,
) -> Pin<Box<dyn Future<Output = Result<Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a JSON-RPC method call with optional session context
Returns domain errors only - dispatcher handles conversion to JSON-RPC errors
Source§fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Option<RequestParams>,
session_context: Option<SessionContext>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Option<RequestParams>,
session_context: Option<SessionContext>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a JSON-RPC notification with optional session context (optional - default does nothing)
Source§fn supported_methods(&self) -> Vec<String>
fn supported_methods(&self) -> Vec<String>
List supported methods (optional - used for introspection)
Auto Trait Implementations§
impl<F, N, E> Freeze for FunctionHandler<F, N, E>
impl<F, N, E> RefUnwindSafe for FunctionHandler<F, N, E>where
F: RefUnwindSafe,
N: RefUnwindSafe,
impl<F, N, E> Send for FunctionHandler<F, N, E>
impl<F, N, E> Sync for FunctionHandler<F, N, E>
impl<F, N, E> Unpin for FunctionHandler<F, N, E>
impl<F, N, E> UnwindSafe for FunctionHandler<F, N, E>where
F: UnwindSafe,
N: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more