[−][src]Struct xaynet_core::message::ChunkBuffer
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| id | message_id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| flags | reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ data (variable length) +
| |
id
: ID of the chunkmessage_id
: ID of the message this chunk belong toflags
: currently the only supported flag indicates whether this is the last chunk or not
Implementations
impl<T: AsRef<[u8]>> ChunkBuffer<T>
[src]
pub fn new(bytes: T) -> Result<Self, DecodeError>
[src]
Performs bound checks for the various message fields on bytes
and returns a new
ChunkBuffer
.
Errors
Fails if the bytes
are smaller than a minimal-sized message buffer.
pub fn new_unchecked(bytes: T) -> Self
[src]
Returns a ChunkBuffer
without performing any bound checks.
This means accessing the various fields may panic if the data is invalid.
pub fn check_buffer_length(&self) -> Result<(), DecodeError>
[src]
Performs bound checks to ensure the fields can be accessed without panicking.
pub fn flags(&self) -> Flags
[src]
Gets the flags field.
Panics
Accessing the field may panic if the buffer has not been checked before.
pub fn id(&self) -> u16
[src]
Gets the chunk ID field
Panics
Accessing the field may panic if the buffer has not been checked before.
pub fn message_id(&self) -> u16
[src]
Gets the message ID field
Panics
Accessing the field may panic if the buffer has not been checked before.
impl<'a, T: AsRef<[u8]> + ?Sized> ChunkBuffer<&'a T>
[src]
pub fn payload(&self) -> &'a [u8]
[src]
Gets the rest of the message.
Panics
Accessing the field may panic if the buffer has not been checked before.
impl<T: AsMut<[u8]> + AsRef<[u8]>> ChunkBuffer<T>
[src]
pub fn set_flags(&mut self, value: Flags)
[src]
Sets the flags field.
Panics
Accessing the field may panic if the buffer has not been checked before.
pub fn set_id(&mut self, value: u16)
[src]
Sets the chunk ID field.
Panics
Accessing the field may panic if the buffer has not been checked before.
pub fn set_message_id(&mut self, value: u16)
[src]
Sets the message ID field.
Panics
Accessing the field may panic if the buffer has not been checked before.
pub fn payload_mut(&mut self) -> &mut [u8]
[src]
Gets a mutable reference to the rest of the message.
Panics
Accessing the field may panic if the buffer has not been checked before.
Auto Trait Implementations
impl<T> RefUnwindSafe for ChunkBuffer<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ChunkBuffer<T> where
T: Send,
T: Send,
impl<T> Sync for ChunkBuffer<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ChunkBuffer<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ChunkBuffer<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,