pub struct Message<'data, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }> { /* private fields */ }
Expand description
A CoAP Message. Use this as a builder structure and then encode the message
Implementations§
Source§impl<'data, const MAX_OPTION_COUNT: usize> Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> Message<'data, MAX_OPTION_COUNT>
Sourcepub fn new(
message_type: Type,
code: Code,
message_id: u16,
token: Token,
options: Vec<CoapOption<'data>, MAX_OPTION_COUNT>,
payload: Option<&'data [u8]>,
) -> Self
pub fn new( message_type: Type, code: Code, message_id: u16, token: Token, options: Vec<CoapOption<'data>, MAX_OPTION_COUNT>, payload: Option<&'data [u8]>, ) -> Self
Initialize with minimum required message parameters.
The Message_Id and the Token are handled internally by CoAP-Zero. Options and a Payload are not required for a valid CoAP Message, but both can be set by the user if needed.
Sourcepub fn new_ack(message_id: u16) -> Self
pub fn new_ack(message_id: u16) -> Self
Convenience constructor for empty ACKs (can not be used for piggybacked responses)
Sourcepub fn message_type(&self) -> Type
pub fn message_type(&self) -> Type
Returns the message type
Sourcepub fn message_id(&self) -> u16
pub fn message_id(&self) -> u16
Returns the message ID
Sourcepub fn options(&self) -> &Vec<CoapOption<'_>, MAX_OPTION_COUNT>
pub fn options(&self) -> &Vec<CoapOption<'_>, MAX_OPTION_COUNT>
Returns a reference to the options vector
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the message code is Code::Empty
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Returns true if the message has a code of Code::Request
Sourcepub fn is_response(&self) -> bool
pub fn is_response(&self) -> bool
Returns true if the message has a code of Code::Response
Trait Implementations§
Source§impl<'data, const MAX_OPTION_COUNT: usize> PartialEq for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> PartialEq for Message<'data, MAX_OPTION_COUNT>
Source§impl<'data, const MAX_OPTION_COUNT: usize> TryFrom<EncodedMessage<'data>> for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> TryFrom<EncodedMessage<'data>> for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> Eq for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> StructuralPartialEq for Message<'data, MAX_OPTION_COUNT>
Auto Trait Implementations§
impl<'data, const MAX_OPTION_COUNT: usize> Freeze for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> RefUnwindSafe for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> Send for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> Sync for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> Unpin for Message<'data, MAX_OPTION_COUNT>
impl<'data, const MAX_OPTION_COUNT: usize> UnwindSafe for Message<'data, MAX_OPTION_COUNT>
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