Trait CoapMessageCommon

Source
pub trait CoapMessageCommon {
Show 15 methods // Required methods fn as_message(&self) -> &CoapMessage; fn as_message_mut(&mut self) -> &mut CoapMessage; // Provided methods 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§

Source

fn as_message(&self) -> &CoapMessage

Returns a reference to this message.

Source

fn as_message_mut(&mut self) -> &mut CoapMessage

Returns a mutable reference to this message.

Provided Methods§

Source

fn add_option(&mut self, option: CoapOption)

Add the supplied CoAP option to this message.

Source

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>

Returns an iterator over the options contained in this message.

Source

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)

Sets the CoAP message type (confirmable, non-confirmable, acknowledgement, rst) of this message.

Source

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)

Sets the message code of this message.

Source

fn mid(&self) -> Option<CoapMessageId>

Returns the CoAP message ID for this message.

Source

fn set_mid(&mut self, mid: Option<CoapMessageId>)

Sets the CoAP message ID for this message.

Source

fn data(&self) -> Option<&[u8]>

Returns a reference to the data/body of this message.

Source

fn set_data<D: Into<Box<[u8]>>>(&mut self, data: Option<D>)

Sets the data/body of this message.

Source

fn token(&self) -> Option<&[u8]>

Returns the message token.

Source

fn set_token<D: Into<Box<[u8]>>>(&mut self, token: Option<D>)

Sets the message token.

Note that CoapSessionCommon::send_request() will automatically set the token to a random value if you don’t.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§