Expand description
The CoAP packet.
Fields
header: Headerpayload: Vec<u8>Implementations
sourceimpl Packet
impl Packet
sourcepub fn options(&self) -> Iter<'_, u16, LinkedList<Vec<u8>>>
pub fn options(&self) -> Iter<'_, u16, LinkedList<Vec<u8>>>
Returns an iterator over the options of the packet.
sourcepub fn get_token(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn get_token(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns the token.
sourcepub fn set_option(&mut self, tp: CoapOption, value: LinkedList<Vec<u8>>)
pub fn set_option(&mut self, tp: CoapOption, value: LinkedList<Vec<u8>>)
Sets an option’s values.
sourcepub fn set_options_as<T: OptionValueType>(
&mut self,
tp: CoapOption,
value: LinkedList<T>
)
pub fn set_options_as<T: OptionValueType>(
&mut self,
tp: CoapOption,
value: LinkedList<T>
)
Sets an option’s values using a structured option value format.
sourcepub fn get_option(&self, tp: CoapOption) -> Option<&LinkedList<Vec<u8>>>
pub fn get_option(&self, tp: CoapOption) -> Option<&LinkedList<Vec<u8>>>
Returns an option’s values.
sourcepub fn get_options_as<T: OptionValueType>(
&self,
tp: CoapOption
) -> Option<LinkedList<Result<T, IncompatibleOptionValueFormat>>>
pub fn get_options_as<T: OptionValueType>(
&self,
tp: CoapOption
) -> Option<LinkedList<Result<T, IncompatibleOptionValueFormat>>>
Returns an option’s values all decoded using the specified structured option value format.
sourcepub fn get_first_option(&self, tp: CoapOption) -> Option<&Vec<u8>>
pub fn get_first_option(&self, tp: CoapOption) -> Option<&Vec<u8>>
Returns an option’s first value as a convenience when only one is expected.
sourcepub fn get_first_option_as<T: OptionValueType>(
&self,
tp: CoapOption
) -> Option<Result<T, IncompatibleOptionValueFormat>>
pub fn get_first_option_as<T: OptionValueType>(
&self,
tp: CoapOption
) -> Option<Result<T, IncompatibleOptionValueFormat>>
Returns an option’s first value as a convenience when only one is expected.
sourcepub fn add_option(&mut self, tp: CoapOption, value: Vec<u8>)
pub fn add_option(&mut self, tp: CoapOption, value: Vec<u8>)
Adds an option value.
sourcepub fn add_option_as<T: OptionValueType>(&mut self, tp: CoapOption, value: T)
pub fn add_option_as<T: OptionValueType>(&mut self, tp: CoapOption, value: T)
Adds an option value using a structured option value format.
sourcepub fn clear_option(&mut self, tp: CoapOption)
pub fn clear_option(&mut self, tp: CoapOption)
Removes an option.
sourcepub fn set_content_format(&mut self, cf: ContentFormat)
pub fn set_content_format(&mut self, cf: ContentFormat)
Sets the content-format.
sourcepub fn get_content_format(&self) -> Option<ContentFormat>
pub fn get_content_format(&self) -> Option<ContentFormat>
Returns the content-format.
sourcepub fn set_observe_value(&mut self, value: u32)
pub fn set_observe_value(&mut self, value: u32)
Sets the value of the observe option.
sourcepub fn get_observe_value(
&self
) -> Option<Result<u32, IncompatibleOptionValueFormat>>
pub fn get_observe_value(
&self
) -> Option<Result<u32, IncompatibleOptionValueFormat>>
Returns the value of the observe option.
sourcepub fn from_bytes(buf: &[u8]) -> Result<Packet, MessageError>
pub fn from_bytes(buf: &[u8]) -> Result<Packet, MessageError>
Decodes a byte slice and constructs the equivalent packet.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnwindSafe for Packet
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more