pub struct Connection { /* private fields */ }Expand description
A bidirectional channel between two end points.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn start_batch(&self) -> Batch
pub fn start_batch(&self) -> Batch
Start a new batch of messages to be sent to the other side
Sourcepub async fn send(&self, batch: Batch) -> Result<()>
pub async fn send(&self, batch: Batch) -> Result<()>
Send a batch of messages to the other side.
Sourcepub async fn recv<R: Pack + 'static, F: FnMut(R) -> bool>(
&self,
f: F,
) -> Result<()>
pub async fn recv<R: Pack + 'static, F: FnMut(R) -> bool>( &self, f: F, ) -> Result<()>
Receive a batch of messages from the other side. Recv will repeatedly call the specified closure with new messages until either,
- the closure returns false
- there are no more messages
Sourcepub async fn try_recv<R: Pack + 'static, F: FnMut(R) -> bool>(
&self,
f: F,
) -> Result<()>
pub async fn try_recv<R: Pack + 'static, F: FnMut(R) -> bool>( &self, f: F, ) -> Result<()>
Receive all available messages, but do not wait for at least 1 message to arrive. If no messages are available return immediatly. This will only block if a concurrent receive is in progress.
Sourcepub async fn recv_one<R: Pack + 'static>(&self) -> Result<R>
pub async fn recv_one<R: Pack + 'static>(&self) -> Result<R>
Wait for one message from the other side, and return it when it is available.
Sourcepub async fn try_recv_one<R: Pack + 'static>(&self) -> Result<Option<R>>
pub async fn try_recv_one<R: Pack + 'static>(&self) -> Result<Option<R>>
Receive a message if one is available, otherwise return Ok(None).
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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