pub struct RequestMultiplexer { /* private fields */ }Expand description
Request multiplexer for handling bidirectional communication
Tracks pending server→client requests and routes responses
Implementations§
Source§impl RequestMultiplexer
impl RequestMultiplexer
Sourcepub fn with_timeout(timeout: Duration) -> Self
pub fn with_timeout(timeout: Duration) -> Self
Create with custom default timeout
Sourcepub fn default_timeout(&self) -> Duration
pub fn default_timeout(&self) -> Duration
Get default timeout
Sourcepub fn create_pending(
&self,
method: impl Into<String>,
) -> (String, Receiver<Result<Value, MultiplexerError>>)
pub fn create_pending( &self, method: impl Into<String>, ) -> (String, Receiver<Result<Value, MultiplexerError>>)
Create a new pending request and return the receiver
Returns (request_id, receiver) - the caller should await the receiver
Sourcepub fn route_response(&self, response: &JsonRpcResponse) -> bool
pub fn route_response(&self, response: &JsonRpcResponse) -> bool
Route an incoming response to its pending request
Returns true if the response was routed, false if no matching request found
Sourcepub fn is_pending_response(&self, id: &Value) -> bool
pub fn is_pending_response(&self, id: &Value) -> bool
Check if a response ID matches a pending request
Used to distinguish client responses from client requests in the message loop
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get number of pending requests
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Cancel all pending requests
Sourcepub fn cleanup_timed_out(&self, timeout: Duration) -> usize
pub fn cleanup_timed_out(&self, timeout: Duration) -> usize
Clean up timed-out requests
Returns the number of requests that were cleaned up
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RequestMultiplexer
impl !RefUnwindSafe for RequestMultiplexer
impl Send for RequestMultiplexer
impl Sync for RequestMultiplexer
impl Unpin for RequestMultiplexer
impl !UnwindSafe for RequestMultiplexer
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