pub struct ConnectDatagram { /* private fields */ }
Expand description
A simple size-prefixed packet format containing a version tag, recipient tag, and message body.
The version tag is decided by the library version and used to maintain backwards compatibility with previous datagram formats.
Implementations§
Source§impl ConnectDatagram
impl ConnectDatagram
Sourcepub fn new(recipient: u16, data: Vec<u8>) -> Result<Self, DatagramError>
pub fn new(recipient: u16, data: Vec<u8>) -> Result<Self, DatagramError>
Creates a new ConnectDatagram
based on an intended recipient and message body.
The version tag is decided by the library version and used to maintain backwards compatibility with previous datagram formats.
This will return a EmptyMessage error if the data
parameter contains no bytes, or in other words, when there is no message body.
This will return a TooLargeMessage error if the data
parameter contains a buffer size greater than 100,000,000 (bytes), or 100MB.
Sourcepub fn take_data(&mut self) -> Option<Vec<u8>>
pub fn take_data(&mut self) -> Option<Vec<u8>>
Takes ownership of the message body of the datagram.
Trait Implementations§
Source§impl Clone for ConnectDatagram
impl Clone for ConnectDatagram
Source§fn clone(&self) -> ConnectDatagram
fn clone(&self) -> ConnectDatagram
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Sink<ConnectDatagram> for ConnectionWriter
impl Sink<ConnectDatagram> for ConnectionWriter
Source§type Error = ConnectionWriteError
type Error = ConnectionWriteError
The type of value produced by the sink when an error occurs.
Source§fn poll_ready(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink
to receive a value. Read moreSource§fn start_send(
self: Pin<&mut Self>,
item: ConnectDatagram,
) -> Result<(), Self::Error>
fn start_send( self: Pin<&mut Self>, item: ConnectDatagram, ) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read moreAuto Trait Implementations§
impl Freeze for ConnectDatagram
impl RefUnwindSafe for ConnectDatagram
impl Send for ConnectDatagram
impl Sync for ConnectDatagram
impl Unpin for ConnectDatagram
impl UnwindSafe for ConnectDatagram
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