riot_wrappers::coap_message

Struct ResponseMessage

Source
pub struct ResponseMessage<'b> {
    message: PacketBuffer<'b>,
    payload_written: Option<usize>,
}
Available on riot_module_gcoap only.

Fields§

§message: PacketBuffer<'b>

Note that this is a slightly weird version of PacketBuffer, where opt_finish is never called, and .payload() perpetually reports the payload marker as part of the payload.

§payload_written: Option<usize>

Implementations§

Source§

impl<'b> ResponseMessage<'b>

Source

pub fn new(buf: PacketBuffer<'b>) -> Self

Source

pub(crate) fn rewind(&mut self)

Source

pub fn finish(&self) -> isize

Trait Implementations§

Source§

impl<'a> MinimalWritableMessage for ResponseMessage<'a>

Source§

type Code = u8

Source§

type OptionNumber = u16

Source§

type AddOptionError = Error

Error returned when an option can not be added (eg. for lack of space, or because an option of a higher number or even the payload was already set)
Source§

type SetPayloadError = Error

Error returned when setting the payload (eg. for lack of space, or when a message of that type does not take a payload)
Source§

type UnionError = Error

Error type into which either of the other errors, as well as the errors for conversion of the Code and OptionNumber, can be .into()ed. Read more
Source§

fn set_code(&mut self, code: Self::Code)

Set the CoAP code of the message (in a request, that is the request method)
Source§

fn add_option( &mut self, number: Self::OptionNumber, value: &[u8], ) -> Result<(), Error>

Add an option to the message Read more
Source§

fn set_payload(&mut self, data: &[u8]) -> Result<(), Error>

Set the payload to the message Read more
Source§

fn promote_to_mutable_writable_message(&mut self) -> Option<&mut Self>

Tries to obtain a MutableWritableMessage from self. Read more
Source§

fn set_from_message<M>(&mut self, msg: &M) -> Result<(), Self::UnionError>

Copy code, options and payload in from a readable message
Source§

fn add_option_str( &mut self, number: Self::OptionNumber, value: &str, ) -> Result<(), Self::AddOptionError>

Shortcut for add_option(self, number, value.as_bytes()). Read more
Source§

fn add_option_uint<U>( &mut self, number: Self::OptionNumber, value: U, ) -> Result<(), Self::AddOptionError>
where U: Unsigned + ToBytes,

Shortcut for add_option on a buffer containing the uint encoded value Read more
Source§

fn with_static_type_annotation( &mut self, ) -> Option<RefMutWithStaticType<'_, Self>>

Type ID of Self or a ’static version of Self Read more
Source§

fn convert_code_error(e: <Self::Code as Code>::Error) -> Self::UnionError

Auxiliary function for converting Self::Code::Error Read more
Source§

fn convert_option_number_error( e: <Self::OptionNumber as OptionNumber>::Error, ) -> Self::UnionError

Auxiliary function for converting Self::OptionNumber::Error Read more
Source§

fn convert_add_option_error(e: Self::AddOptionError) -> Self::UnionError

Auxiliary function for converting Self::AddOptionError Read more
Source§

fn convert_set_payload_error(e: Self::SetPayloadError) -> Self::UnionError

Auxiliary function for converting Self::SetPayloadError Read more
Source§

impl<'a> MutableWritableMessage for ResponseMessage<'a>

Source§

fn available_space(&self) -> usize

Number of bytes available for additional options, payload marker and payload
Source§

fn payload_mut_with_len(&mut self, len: usize) -> Result<&mut [u8], Error>

Memory-map len bytes of the payload for writing Read more
Source§

fn truncate(&mut self, len: usize) -> Result<(), Error>

Truncate an already-set payload to the given length; that payload must have been written to before using MinimalWritableMessage::set_payload, or with a suitable MutableWritableMessage::payload_mut_with_len call.
Source§

fn mutate_options<F>(&mut self, callback: F)
where F: FnMut(Self::OptionNumber, &mut [u8]),

Apply a callback to all options in sequence Read more

Auto Trait Implementations§

§

impl<'b> Freeze for ResponseMessage<'b>

§

impl<'b> RefUnwindSafe for ResponseMessage<'b>

§

impl<'b> !Send for ResponseMessage<'b>

§

impl<'b> !Sync for ResponseMessage<'b>

§

impl<'b> Unpin for ResponseMessage<'b>

§

impl<'b> !UnwindSafe for ResponseMessage<'b>

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> 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> IntoSwitch for T

Source§

fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
Source§

fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
Source§

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. 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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 20 bytes