pub struct RawPacket { /* private fields */ }Available on crate feature
web03 only.Expand description
A raw packet of data.
Implementations§
Source§impl RawPacket
impl RawPacket
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Construct an empty raw packet.
§Examples
use musli_web::api::MessageId;
use musli_web::web::RawPacket;
let packet = RawPacket::empty();
assert!(packet.is_empty());
assert_eq!(packet.id(), MessageId::EMPTY);Sourcepub fn decode<'this, T>(&'this self) -> Result<T, Error>
pub fn decode<'this, T>(&'this self) -> Result<T, Error>
Decode the contents of a raw packet.
This can be called multiple times if there are multiple payloads in sequence of the response.
You can check if the packet is empty using RawPacket::is_empty.
Sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Get the underlying byte slice of the packet.
§Examples
use musli_web::web::RawPacket;
let packet = RawPacket::empty();
assert_eq!(packet.as_slice(), &[]);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of the packet.
§Examples
use musli_web::web::RawPacket;
let packet = RawPacket::empty();
assert_eq!(packet.len(), 0);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the packet is empty.
§Examples
use musli_web::web::RawPacket;
let packet = RawPacket::empty();
assert!(packet.is_empty());Sourcepub fn id(&self) -> MessageId
pub fn id(&self) -> MessageId
The id of the packet this is a response to as specified by
Endpoint::ID or Broadcast::ID.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RawPacket
impl !RefUnwindSafe for RawPacket
impl !Send for RawPacket
impl !Sync for RawPacket
impl Unpin for RawPacket
impl !UnwindSafe for RawPacket
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.