pub struct ClientMessagesHandler {
    pub transport: Arc<dyn Transport + Send + Sync>,
    pub streams_handler: Arc<StreamsHandler>,
    /* private fields */
}
Expand description

ClientMessagesHandler is in charge of sending message through the transport, processing the responses and sending them through their attached listeners

It runs a background task listening for new messages (responses) in the given transport.

It’s the data structure that actually owns the Transport attached to a RpcClient. The transport is drilled down up to get to ClientMEssagesHandler

Fields§

§transport: Arc<dyn Transport + Send + Sync>

Transport received by a RpcClient

§streams_handler: Arc<StreamsHandler>

Data structure in charge of handling all messages related to streams

Implementations§

source§

impl ClientMessagesHandler

source

pub fn new(transport: Arc<dyn Transport + Send + Sync>) -> Self

source

pub fn start(self: Arc<Self>)

Starts a background task to listen responses from the crate::server::RpcServer sent to the transport.

The receiver is an Arc<Self> in order to be able to process in a backgroun taks and mutate the state of the listeners

source

pub fn stop(&self)

Stops the background task listening responses in the transport

source

pub fn await_server_ack_open_and_send_streams<M: Message + 'static>( self: Arc<Self>, open_promise: OneShotReceiver<Vec<u8>>, client_stream: Generator<M>, port_id: u32, client_message_id: u32 )

It spawns a background task to wait for the server to acknowledge the open of client streams or biderectional streams.

After the server acknowledges the open, it starts sending stram messages.

The receiver of the function is an Arc<Self> because an instance should be cloned for the background task and mutate the state of the message listeners

source

pub async fn register_one_time_listener( &self, message_id: u32, callback: OneShotSender<Vec<u8>> )

Registers a one time listener. It will be used only one time and then removed.

source

pub async fn register_listener( &self, message_id: u32, callback: AsyncChannelSender<(RpcMessageTypes, u32, StreamMessage)> )

Registers a listener which will be more than one time

source

pub async fn unregister_listener(&self, message_id: u32)

Unregister a listener

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more