[][src]Struct coap_lite::Packet

pub struct Packet {
    pub header: Header,
    pub payload: Vec<u8>,
    // some fields omitted
}

The CoAP packet.

Fields

header: Headerpayload: Vec<u8>

Methods

impl Packet[src]

pub fn new() -> Packet[src]

Creates a new packet.

pub fn options(&self) -> Iter<'a, usize, LinkedList<Vec<u8>>>[src]

Returns an iterator over the options of the packet.

pub fn set_token(&mut self, token: Vec<u8>)[src]

Sets the token.

pub fn get_token(&self) -> &Vec<u8>[src]

Returns the token.

pub fn set_option(&mut self, tp: CoapOption, value: LinkedList<Vec<u8>>)[src]

Sets an option's values.

pub fn get_option(&self, tp: CoapOption) -> Option<&LinkedList<Vec<u8>>>[src]

Returns an option's values.

pub fn add_option(&mut self, tp: CoapOption, value: Vec<u8>)[src]

Adds an option value.

pub fn clear_option(&mut self, tp: CoapOption)[src]

Removes an option.

pub fn set_content_format(&mut self, cf: ContentFormat)[src]

Sets the content-format.

pub fn get_content_format(&self) -> Option<ContentFormat>[src]

Returns the content-format.

pub fn set_observe(&mut self, value: Vec<u8>)[src]

Sets the value of the observe option.

pub fn get_observe(&self) -> Option<&Vec<u8>>[src]

Returns the value of the observe option.

pub fn from_bytes(buf: &[u8]) -> Result<Packet, MessageError>[src]

Decodes a byte slice and constructs the equivalent packet.

pub fn to_bytes(&self) -> Result<Vec<u8>, MessageError>[src]

Returns a vector of bytes representing the Packet.

Trait Implementations

impl Default for Packet[src]

impl Clone for Packet[src]

impl Debug for Packet[src]

Auto Trait Implementations

impl Send for Packet

impl Unpin for Packet

impl Sync for Packet

impl UnwindSafe for Packet

impl RefUnwindSafe for Packet

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

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

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, 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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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