Struct libcoap_rs::message::CoapMessage
source · pub struct CoapMessage { /* private fields */ }
Expand description
Representation of a CoAP message.
Implementations
sourceimpl 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
sourceimpl Clone for CoapMessage
impl Clone for CoapMessage
sourcefn clone(&self) -> CoapMessage
fn clone(&self) -> CoapMessage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl CoapMessageCommon for CoapMessage
impl CoapMessageCommon for CoapMessage
sourcefn as_message(&self) -> &CoapMessage
fn as_message(&self) -> &CoapMessage
Returns a reference to this message.
sourcefn as_message_mut(&mut self) -> &mut CoapMessage
fn as_message_mut(&mut self) -> &mut CoapMessage
Returns a mutable reference to this message.
sourcefn add_option(&mut self, option: CoapOption)
fn add_option(&mut self, option: CoapOption)
Add the supplied CoAP option to this message.
sourcefn clear_options(&mut self)
fn clear_options(&mut self)
Clear the list of options that were added to this message using add_option().
sourcefn options_iter(&self) -> Iter<'_, CoapOption>
fn options_iter(&self) -> Iter<'_, CoapOption>
Returns an iterator over the options contained in this message.
sourcefn type_(&self) -> CoapMessageType
fn type_(&self) -> CoapMessageType
Returns the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.
sourcefn 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.
sourcefn 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. Read more
sourcefn 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.
sourcefn mid(&self) -> Option<CoapMessageId>
fn mid(&self) -> Option<CoapMessageId>
Returns the CoAP message ID for this message.
sourcefn set_mid(&mut self, mid: Option<CoapMessageId>)
fn set_mid(&mut self, mid: Option<CoapMessageId>)
Sets the CoAP message ID for this message.
sourceimpl Debug for CoapMessage
impl Debug for CoapMessage
sourceimpl From<CoapRequest> for CoapMessage
impl From<CoapRequest> for CoapMessage
sourcefn from(val: CoapRequest) -> Self
fn from(val: CoapRequest) -> Self
Converts to this type from the input type.
sourceimpl From<CoapResponse> for CoapMessage
impl From<CoapResponse> for CoapMessage
sourcefn from(val: CoapResponse) -> Self
fn from(val: CoapResponse) -> Self
Converts to this type from the input type.
sourceimpl Hash for CoapMessage
impl Hash for CoapMessage
sourceimpl PartialEq<CoapMessage> for CoapMessage
impl PartialEq<CoapMessage> for CoapMessage
sourcefn eq(&self, other: &CoapMessage) -> bool
fn eq(&self, other: &CoapMessage) -> bool
impl Eq for CoapMessage
impl StructuralEq for CoapMessage
impl StructuralPartialEq for CoapMessage
Auto Trait Implementations
impl RefUnwindSafe for CoapMessage
impl Send for CoapMessage
impl Sync for CoapMessage
impl Unpin for CoapMessage
impl UnwindSafe for CoapMessage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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