pub struct CoapOption {
pub number: u16,
pub value: Vec<u8>,
}Expand description
A single CoAP option (RFC 7252 §3.1).
Options are TLV-encoded in messages, sorted by option number. Repeated option numbers create multiple values for that option.
Fields§
§number: u16Option number (determines semantics).
value: Vec<u8>Option value (interpretation depends on the option number).
Implementations§
Source§impl CoapOption
impl CoapOption
Sourcepub fn new(number: u16, value: Vec<u8>) -> Self
pub fn new(number: u16, value: Vec<u8>) -> Self
Creates a new option with the given number and value.
Sourcepub fn value_as_uint(&self) -> u32
pub fn value_as_uint(&self) -> u32
Interprets the option value as a variable-length unsigned integer.
RFC 7252 §3.2: Options with format “uint” use 0-4 bytes in network byte order.
Sourcepub fn from_uint(number: u16, value: u32) -> Self
pub fn from_uint(number: u16, value: u32) -> Self
Creates an option with a uint value encoded in the minimum number of bytes.
Sourcepub fn value_as_str(&self) -> CoapResult<&str>
pub fn value_as_str(&self) -> CoapResult<&str>
Interprets the option value as a UTF-8 string.
Trait Implementations§
Source§impl Clone for CoapOption
impl Clone for CoapOption
Source§fn clone(&self) -> CoapOption
fn clone(&self) -> CoapOption
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 Debug for CoapOption
impl Debug for CoapOption
Source§impl PartialEq for CoapOption
impl PartialEq for CoapOption
impl Eq for CoapOption
impl StructuralPartialEq for CoapOption
Auto Trait Implementations§
impl Freeze for CoapOption
impl RefUnwindSafe for CoapOption
impl Send for CoapOption
impl Sync for CoapOption
impl Unpin for CoapOption
impl UnsafeUnpin for CoapOption
impl UnwindSafe for CoapOption
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