Struct de_net::OutPackage
source · pub struct OutPackage {
data: Vec<u8>,
reliability: Reliability,
peers: Peers,
target: SocketAddr,
}
Expand description
A package to be send.
Fields§
§data: Vec<u8>
First HEADER_SIZE
bytes are reserved for the header. Payload must
follow.
reliability: Reliability
§peers: Peers
§target: SocketAddr
Implementations§
source§impl OutPackage
impl OutPackage
sourcepub fn encode_single<E>(
message: &E,
reliability: Reliability,
peers: Peers,
target: SocketAddr
) -> Result<Self, EncodeError>where
E: Encode,
pub fn encode_single<E>(
message: &E,
reliability: Reliability,
peers: Peers,
target: SocketAddr
) -> Result<Self, EncodeError>where
E: Encode,
Creates a package from a single message.
sourcepub fn from_slice(
data: &[u8],
reliability: Reliability,
peers: Peers,
target: SocketAddr
) -> Self
pub fn from_slice( data: &[u8], reliability: Reliability, peers: Peers, target: SocketAddr ) -> Self
§Panics
If data
is longer than MAX_PACKAGE_SIZE
.
sourcepub(super) fn new(
data: Vec<u8>,
reliability: Reliability,
peers: Peers,
target: SocketAddr
) -> Self
pub(super) fn new( data: Vec<u8>, reliability: Reliability, peers: Peers, target: SocketAddr ) -> Self
§Arguments
-
data
- data to be send. The message data must start exactly atHEADER_SIZE
. The initial bytes are reserved for the header. The header is not filled by the caller. -
reliability
- package delivery reliability mode. -
target
- package recipient.
§Panics
-
If data length is smaller or equal to header size..
-
If data is longer than
MAX_DATAGRAM_SIZE
.
sourcepub(crate) fn data(self) -> Vec<u8>
pub(crate) fn data(self) -> Vec<u8>
Returns package data.
The data start at HEADER_SIZE
so that header may be written
to the beginning of the vector.
sourcepub(crate) fn data_slice(&self) -> &[u8] ⓘ
pub(crate) fn data_slice(&self) -> &[u8] ⓘ
Returns slice to the payload part (without header) of the data.
pub(crate) fn reliability(&self) -> Reliability
pub(crate) fn peers(&self) -> Peers
pub(crate) fn target(&self) -> SocketAddr
Auto Trait Implementations§
impl Freeze for OutPackage
impl RefUnwindSafe for OutPackage
impl Send for OutPackage
impl Sync for OutPackage
impl Unpin for OutPackage
impl UnwindSafe for OutPackage
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