ServerMessagesHandler

Struct ServerMessagesHandler 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

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

Source§

fn default() -> ServerMessagesHandler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.