Trait libcoap_rs::message::CoapMessageCommon
source · pub trait CoapMessageCommon {
Show 15 methods
fn as_message(&self) -> &CoapMessage;
fn as_message_mut(&mut self) -> &mut CoapMessage;
fn add_option(&mut self, option: CoapOption) { ... }
fn clear_options(&mut self) { ... }
fn options_iter(&self) -> Iter<'_, CoapOption> { ... }
fn type_(&self) -> CoapMessageType { ... }
fn set_type_(&mut self, type_: CoapMessageType) { ... }
fn code(&self) -> CoapMessageCode { ... }
fn set_code<C: Into<CoapMessageCode>>(&mut self, code: C) { ... }
fn mid(&self) -> Option<CoapMessageId> { ... }
fn set_mid(&mut self, mid: Option<CoapMessageId>) { ... }
fn data(&self) -> Option<&[u8]> { ... }
fn set_data<D: Into<Box<[u8]>>>(&mut self, data: Option<D>) { ... }
fn token(&self) -> Option<&[u8]> { ... }
fn set_token<D: Into<Box<[u8]>>>(&mut self, token: Option<D>) { ... }
}
Expand description
Interface for CoAP messages common between requests, responses and other messages.
Required Methods
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.
Provided Methods
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.
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.