pub struct CltSender<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> { /* private fields */ }
Expand description

An abstraction over a MessageSender that executes crate::prelude::ProtocolCore::on_send, crate::prelude::ProtocolCore::on_sent/crate::prelude::ProtocolCore::on_wouldblock/crate::prelude::ProtocolCore::on_error and CallbackSend::on_sent on every message processed by CltSender. It is designed to work in a single thread that is different from CltRecver thread

§Important

This is an owned implementation and is not Cloneable.

§Warning

Dropping CltSender will also result in termination of the connection in the paired CltRecver instance

Implementations§

source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> CltSender<P, C, MAX_MSG_SIZE>

source

pub fn new( sender: MessageSender<P, MAX_MSG_SIZE>, callback: Arc<C>, protocol: Arc<P>, acceptor_connection_gate: Option<RemoveConnectionBarrierOnDrop> ) -> Self

Trait Implementations§

source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ConnectionId for CltSender<P, C, MAX_MSG_SIZE>

source§

fn con_id(&self) -> &ConId

source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ConnectionStatus for CltSender<P, C, MAX_MSG_SIZE>

source§

fn is_connected(&self) -> bool

logical check of connection status
source§

fn is_connected_busywait_timeout(&self, timeout: Duration) -> bool

source§

impl<P: Debug + Protocol, C: Debug + CallbackSend<P>, const MAX_MSG_SIZE: usize> Debug for CltSender<P, C, MAX_MSG_SIZE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Display for CltSender<P, C, MAX_MSG_SIZE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Drop for CltSender<P, C, MAX_MSG_SIZE>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ReSendNonBlocking<<P as Messenger>::SendT> for CltSender<P, C, MAX_MSG_SIZE>

source§

fn re_send(&mut self, msg: &P::SendT) -> Result<SendStatus, Error>

The call will internally serialize the msg and attempt to write the resulting bytes into a stream. If there was a successfull attempt which wrote some bytes from serialized message into the stream but the write was only partial then the call will busy wait until all of remaining bytes were written before returning SendStatus::Completed. SendStatus::WouldBlock is returned only if the attempt did not write any bytes to the stream after the first attempt Read more
source§

fn re_send_busywait_timeout( &mut self, msg: &T, timeout: Duration ) -> Result<SendStatus, Error>

Will call Self::re_send until it returns SendStatus::Completed or SendStatus::WouldBlock after the timeout,
source§

fn re_send_busywait(&mut self, msg: &T) -> Result<(), Error>

Will call Self::re_send until it returns SendStatus::Completed
source§

impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> SendNonBlocking<<P as Messenger>::SendT> for CltSender<P, C, MAX_MSG_SIZE>

source§

fn send( &mut self, msg: &mut <P as Messenger>::SendT ) -> Result<SendStatus, Error>

The call will internally serialize the T and attempt to write the resulting bytes into a stream. If there was a successfull attempt which wrote some, not all, bytes from serialized message into the stream and hence the write was only partial, the call will busy wait until all of remaining bytes are written before returning SendStatus::Completed. SendStatus::WouldBlock is returned only if the attempt did not write any bytes to the stream after the first attempt Read more
source§

fn send_busywait_timeout( &mut self, msg: &mut <P as Messenger>::SendT, timeout: Duration ) -> Result<SendStatus, Error>

Will call Self::send until it returns SendStatus::Completed or SendStatus::WouldBlock after the timeout, while propagating all errors from Self::send Read more
source§

fn send_busywait( &mut self, msg: &mut <P as Messenger>::SendT ) -> Result<(), Error>

Will call Self::send until it returns SendStatus::Completed Read more

Auto Trait Implementations§

§

impl<P, C, const MAX_MSG_SIZE: usize> RefUnwindSafe for CltSender<P, C, MAX_MSG_SIZE>

§

impl<P, C, const MAX_MSG_SIZE: usize> Send for CltSender<P, C, MAX_MSG_SIZE>
where C: Sync + Send,

§

impl<P, C, const MAX_MSG_SIZE: usize> Sync for CltSender<P, C, MAX_MSG_SIZE>
where C: Sync + Send,

§

impl<P, C, const MAX_MSG_SIZE: usize> Unpin for CltSender<P, C, MAX_MSG_SIZE>
where P: Unpin,

§

impl<P, C, const MAX_MSG_SIZE: usize> UnwindSafe for CltSender<P, C, MAX_MSG_SIZE>

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.