pub struct RpcRouter { /* private fields */ }Expand description
Thread-safe registry mapping JSON-RPC method names to async handlers with zero-allocation lookup.
Implementations§
Source§impl RpcRouter
Inherent implementation of RpcRouter.
impl RpcRouter
Inherent implementation of RpcRouter.
Sourcepub fn add_interceptor(
&mut self,
interceptor: Arc<dyn RpcInterceptor>,
) -> &mut Self
pub fn add_interceptor( &mut self, interceptor: Arc<dyn RpcInterceptor>, ) -> &mut Self
Registers an extensible RpcInterceptor invoked before every method dispatch.
§Arguments
Arc<dyn RpcInterceptor>- Interceptor implementation.
§Returns
&mut Self- This router for fluent chaining.
Sourcepub fn has_method(&self, name: &str) -> bool
pub fn has_method(&self, name: &str) -> bool
Sourcepub fn method_names(&self) -> Vec<String>
pub fn method_names(&self) -> Vec<String>
Sourcepub async fn dispatch_value(&self, raw: Value) -> Option<RpcResponse>
pub async fn dispatch_value(&self, raw: Value) -> Option<RpcResponse>
Sourcepub async fn dispatch_bytes(
&self,
raw: &[u8],
config: &RpcConfig,
) -> Option<Vec<u8>>
pub async fn dispatch_bytes( &self, raw: &[u8], config: &RpcConfig, ) -> Option<Vec<u8>>
Parses and dispatches raw JSON-RPC 2.0 request bytes (single call, notification, or concurrent batch).
§Arguments
&[u8]- Raw HTTP request payload bytes.&RpcConfig- Batch and payload safety bounds.
§Returns
Option<Vec<u8>>- Serialized JSON response bytes, orNonewhen every call was a notification.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RpcRouter
impl !UnwindSafe for RpcRouter
impl Forget for RpcRouter
impl Freeze for RpcRouter
impl Move for RpcRouter
impl Send for RpcRouter
impl Sync for RpcRouter
impl Unpin for RpcRouter
impl UnsafeUnpin for RpcRouterwhere
PhantomData<fn() -> FxHasher>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Arc<dyn Fn(Option<Value>) -> Pin<Box<dyn Future<Output = Result<Value, RpcError>> + Send>> + Sync + Send>)>: UnsafeUnpin,
PhantomData<Arc<dyn RpcInterceptor>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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