Struct links_nonblocking::connect::clt::CltSender
source · 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>
impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> CltSender<P, C, MAX_MSG_SIZE>
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>
impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ConnectionId for CltSender<P, C, MAX_MSG_SIZE>
source§impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ConnectionStatus for CltSender<P, C, MAX_MSG_SIZE>
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
fn is_connected(&self) -> bool
logical check of connection status
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>
impl<P: Debug + Protocol, C: Debug + CallbackSend<P>, const MAX_MSG_SIZE: usize> Debug for CltSender<P, C, MAX_MSG_SIZE>
source§impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Display for CltSender<P, C, MAX_MSG_SIZE>
impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Display for CltSender<P, C, MAX_MSG_SIZE>
source§impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Drop for CltSender<P, C, MAX_MSG_SIZE>
impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> Drop for CltSender<P, C, MAX_MSG_SIZE>
source§impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> ReSendNonBlocking<<P as Messenger>::SendT> for CltSender<P, C, MAX_MSG_SIZE>
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>
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>
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>
fn re_send_busywait(&mut self, msg: &T) -> Result<(), Error>
Will call
Self::re_send
until it returns SendStatus::Completedsource§impl<P: Protocol, C: CallbackSend<P>, const MAX_MSG_SIZE: usize> SendNonBlocking<<P as Messenger>::SendT> for CltSender<P, C, MAX_MSG_SIZE>
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>
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 moresource§fn send_busywait_timeout(
&mut self,
msg: &mut <P as Messenger>::SendT,
timeout: Duration
) -> Result<SendStatus, Error>
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
Auto Trait Implementations§
impl<P, C, const MAX_MSG_SIZE: usize> RefUnwindSafe for CltSender<P, C, MAX_MSG_SIZE>where
C: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, C, const MAX_MSG_SIZE: usize> Send for CltSender<P, C, MAX_MSG_SIZE>
impl<P, C, const MAX_MSG_SIZE: usize> Sync for CltSender<P, C, MAX_MSG_SIZE>
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> 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