pub struct ServerMessagesHandler {
pub streams_handler: Arc<StreamsHandler>,
/* private fields */
}Expand description
It’s in charge of handling every request that the client sends
It spawns a background tasks to process every request
Fields§
§streams_handler: Arc<StreamsHandler>Data structure in charge of handling all messages related to streams
Implementations§
Source§impl ServerMessagesHandler
impl ServerMessagesHandler
pub fn new() -> Self
Sourcepub fn process_unary_request<T: Transport + ?Sized + 'static>(
&self,
transport: Arc<T>,
message_number: u32,
procedure_handler: UnaryResponse,
)
pub fn process_unary_request<T: Transport + ?Sized + 'static>( &self, transport: Arc<T>, message_number: u32, procedure_handler: UnaryResponse, )
Receive a unary procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
Sourcepub fn process_server_streams_request<T: Transport + ?Sized + 'static>(
self: Arc<Self>,
transport: Arc<T>,
message_number: u32,
port_id: u32,
procedure_handler: ServerStreamsResponse,
)
pub fn process_server_streams_request<T: Transport + ?Sized + 'static>( self: Arc<Self>, transport: Arc<T>, message_number: u32, port_id: u32, procedure_handler: ServerStreamsResponse, )
Receive a server streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
Sourcepub fn process_client_streams_request<T: Transport + ?Sized + 'static>(
self: Arc<Self>,
transport: Arc<T>,
message_number: u32,
client_stream_id: u32,
procedure_handler: ClientStreamsResponse,
listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>,
)
pub fn process_client_streams_request<T: Transport + ?Sized + 'static>( self: Arc<Self>, transport: Arc<T>, message_number: u32, client_stream_id: u32, procedure_handler: ClientStreamsResponse, listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>, )
Receive a client streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
Sourcepub fn process_bidir_streams_request<T: Transport + ?Sized + 'static>(
self: Arc<Self>,
transport: Arc<T>,
message_number: u32,
port_id: u32,
client_stream_id: u32,
listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>,
procedure_handler: BiStreamsResponse,
)
pub fn process_bidir_streams_request<T: Transport + ?Sized + 'static>( self: Arc<Self>, transport: Arc<T>, message_number: u32, port_id: u32, client_stream_id: u32, listener: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>, procedure_handler: BiStreamsResponse, )
Receive a bidirectional streams procedure handler returned future and process it in a spawned background task.
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
Sourcepub fn notify_new_client_stream(
self: Arc<Self>,
message_number: u32,
payload: Vec<u8>,
)
pub fn notify_new_client_stream( self: Arc<Self>, message_number: u32, payload: Vec<u8>, )
Notify the listener for a client streams procedure that the client sent a new StreamMessage
This function aims to run the procedure handler in spawned task to achieve processing requests concurrently.
Sourcepub async fn send_response<T: Transport + ?Sized>(
&self,
transport: Arc<T>,
message_number: u32,
payload: Vec<u8>,
)
pub async fn send_response<T: Transport + ?Sized>( &self, transport: Arc<T>, message_number: u32, payload: Vec<u8>, )
Sends a common response Response through the given transport
If it fails to send the response, it will retry it as long as the Transport::send doesn’t return a TransportError::Closed
Sourcepub async fn register_listener(
&self,
message_id: u32,
callback: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>,
)
pub async fn register_listener( &self, message_id: u32, callback: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)>, )
Register a listener for a specific message_id used for client and bidirectional streams
Sourcepub async fn unregister_listener(&self, message_id: u32)
pub async fn unregister_listener(&self, message_id: u32)
Unregister a listener for a specific message_id used for client and bidirectional streams
Trait Implementations§
Source§impl Default for ServerMessagesHandler
impl Default for ServerMessagesHandler
Source§fn default() -> ServerMessagesHandler
fn default() -> ServerMessagesHandler
Auto Trait Implementations§
impl !Freeze for ServerMessagesHandler
impl !RefUnwindSafe for ServerMessagesHandler
impl Send for ServerMessagesHandler
impl Sync for ServerMessagesHandler
impl Unpin for ServerMessagesHandler
impl !UnwindSafe for ServerMessagesHandler
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more