pub struct CoapMessage { /* private fields */ }
Expand description
Representation of a CoAP message.
Implementations§
Source§impl CoapMessage
impl CoapMessage
Sourcepub fn new(type_: CoapMessageType, code: CoapMessageCode) -> CoapMessage
pub fn new(type_: CoapMessageType, code: CoapMessageCode) -> CoapMessage
Creates a new CoAP message with the given type and code.
Sourcepub unsafe fn from_raw_pdu(
raw_pdu: *const coap_pdu_t,
) -> Result<CoapMessage, MessageConversionError>
pub unsafe fn from_raw_pdu( raw_pdu: *const coap_pdu_t, ) -> Result<CoapMessage, MessageConversionError>
Parses the given raw coap_pdu_t into a CoapMessage.
§Safety
raw_pdu must point to a valid instance of coap_pdu_t.
Sourcepub fn into_raw_pdu<'a, S: CoapSessionCommon<'a> + ?Sized>(
self,
session: &S,
) -> Result<*mut coap_pdu_t, MessageConversionError>
pub fn into_raw_pdu<'a, S: CoapSessionCommon<'a> + ?Sized>( self, session: &S, ) -> Result<*mut coap_pdu_t, MessageConversionError>
Converts this message into a raw PDU suitable for sending using the raw coap_send() function.
The caller is responsible for freeing the returned PDU, either by calling coap_send() or [coap_delete_pdu()].
Trait Implementations§
Source§impl Clone for CoapMessage
impl Clone for CoapMessage
Source§fn clone(&self) -> CoapMessage
fn clone(&self) -> CoapMessage
Returns a copy 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 CoapMessageCommon for CoapMessage
impl CoapMessageCommon for CoapMessage
Source§fn as_message(&self) -> &CoapMessage
fn as_message(&self) -> &CoapMessage
Returns a reference to this message.
Source§fn as_message_mut(&mut self) -> &mut CoapMessage
fn as_message_mut(&mut self) -> &mut CoapMessage
Returns a mutable reference to this message.
Source§fn add_option(&mut self, option: CoapOption)
fn add_option(&mut self, option: CoapOption)
Add the supplied CoAP option to this message.
Source§fn clear_options(&mut self)
fn clear_options(&mut self)
Clear the list of options that were added to this message using add_option().
Source§fn options_iter(&self) -> Iter<'_, CoapOption>
fn options_iter(&self) -> Iter<'_, CoapOption>
Returns an iterator over the options contained in this message.
Source§fn type_(&self) -> CoapMessageType
fn type_(&self) -> CoapMessageType
Returns the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.
Source§fn set_type_(&mut self, type_: CoapMessageType)
fn set_type_(&mut self, type_: CoapMessageType)
Sets the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.
Source§fn code(&self) -> CoapMessageCode
fn code(&self) -> CoapMessageCode
Returns the message code of this message.
To determine whether the message is a request or response, use CoapMessageCode::try_from()
and match for the enum variants.
Source§fn set_code<C: Into<CoapMessageCode>>(&mut self, code: C)
fn set_code<C: Into<CoapMessageCode>>(&mut self, code: C)
Sets the message code of this message.
Source§fn mid(&self) -> Option<CoapMessageId>
fn mid(&self) -> Option<CoapMessageId>
Returns the CoAP message ID for this message.
Source§fn set_mid(&mut self, mid: Option<CoapMessageId>)
fn set_mid(&mut self, mid: Option<CoapMessageId>)
Sets the CoAP message ID for this message.
Source§impl Debug for CoapMessage
impl Debug for CoapMessage
Source§impl From<CoapRequest> for CoapMessage
impl From<CoapRequest> for CoapMessage
Source§fn from(val: CoapRequest) -> Self
fn from(val: CoapRequest) -> Self
Converts to this type from the input type.
Source§impl From<CoapResponse> for CoapMessage
impl From<CoapResponse> for CoapMessage
Source§fn from(val: CoapResponse) -> Self
fn from(val: CoapResponse) -> Self
Converts to this type from the input type.
Source§impl Hash for CoapMessage
impl Hash for CoapMessage
Source§impl PartialEq for CoapMessage
impl PartialEq for CoapMessage
impl Eq for CoapMessage
impl StructuralPartialEq for CoapMessage
Auto Trait Implementations§
impl Freeze for CoapMessage
impl RefUnwindSafe for CoapMessage
impl Send for CoapMessage
impl Sync for CoapMessage
impl Unpin for CoapMessage
impl UnwindSafe for CoapMessage
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