Struct CoapMessage

Source
pub struct CoapMessage { /* private fields */ }
Expand description

Representation of a CoAP message.

Implementations§

Source§

impl CoapMessage

Source

pub fn new(type_: CoapMessageType, code: CoapMessageCode) -> CoapMessage

Creates a new CoAP message with the given type and code.

Source

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.

Source

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

Source§

fn clone(&self) -> CoapMessage

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CoapMessageCommon for CoapMessage

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.
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. Read more
Source§

impl Debug for CoapMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<CoapRequest> for CoapMessage

Source§

fn from(val: CoapRequest) -> Self

Converts to this type from the input type.
Source§

impl From<CoapResponse> for CoapMessage

Source§

fn from(val: CoapResponse) -> Self

Converts to this type from the input type.
Source§

impl Hash for CoapMessage

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CoapMessage

Source§

fn eq(&self, other: &CoapMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for CoapMessage

Source§

impl StructuralPartialEq for CoapMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T