[][src]Struct mynewt::encoding::coap_context::CoapContext

pub struct CoapContext {
    key_buffer: [u8; 32],
    value_buffer: [u8; 32],
}

CoAP encoder state. Buffers the next key and value to be encoded.

Fields

key_buffer: [u8; 32]

Static buffer for the key to be encoded. Will be passed to Mynewt COAP encoder API. Always null-terminated.

value_buffer: [u8; 32]

Static buffer for the string value to be encoded. Will be passed to Mynewt COAP encoder API. Always null-terminated.

Methods

impl CoapContext[src]

pub fn json_set_text_string(&mut self, key: &Strn, value: &Strn)[src]

pub fn key_to_cstr(&mut self, s: &[u8]) -> *const u8[src]

Given a key s, return a *char pointer that is null-terminated. Used for encoding COAP keys. If s is null-terminated, return it as a pointer. Else copy s to the static buffer, append null and return the buffer as a pointer.

pub fn value_to_cstr(&mut self, s: &[u8]) -> *const u8[src]

Given a value s, return a *char pointer that is null-terminated. Used for encoding COAP values. If s is null-terminated, return it as a pointer. Else copy s to the static buffer, append null and return the buffer as a pointer.

pub fn cstr_len(&self, s: &[u8]) -> usize[src]

Compute the byte length of the string in s. If s is null-terminated, return length of s - 1. Else return length of s.

pub fn global_encoder(&self) -> *mut CborEncoder[src]

Return the global CBOR encoder

pub fn new_encoder(&self, key: &str, suffix: &str) -> *mut CborEncoder[src]

Create a new CBOR encoder for the current map or array, e.g. key=root, suffix=_map

pub fn encoder(&self, key: &str, suffix: &str) -> *mut CborEncoder[src]

Return the CBOR encoder for the current map or array, e.g. key=root, suffix=_map

pub fn check_result(&self, res: u32)[src]

Fail the encoding with an error if res is non-zero.

pub fn fail(&mut self, err: CoapError)[src]

Fail the encoding with an error

pub fn to_void_ptr(&mut self) -> *mut c_void[src]

Cast itself as a *mut c_void

Trait Implementations

impl Default for CoapContext[src]

Auto Trait Implementations

impl Send for CoapContext

impl Sync for CoapContext

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]