Struct coap::client::CoAPClient

source ·
pub struct CoAPClient { /* private fields */ }

Implementations§

source§

impl CoAPClient

source

pub fn new_with_specific_source<A: ToSocketAddrs, B: ToSocketAddrs>( bind_addr: A, peer_addr: B ) -> Result<CoAPClient>

Create a CoAP client with the specific source and peer address.

source

pub fn new<A: ToSocketAddrs>(addr: A) -> Result<CoAPClient>

Create a CoAP client with the peer address.

source

pub fn get(url: &str) -> Result<CoapResponse>

Execute a single get request with a coap url

source

pub fn get_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>

Execute a single get request with a coap url and a specific timeout.

source

pub fn post(url: &str, data: Vec<u8>) -> Result<CoapResponse>

Execute a single post request with a coap url

source

pub fn post_with_timeout( url: &str, data: Vec<u8>, timeout: Duration ) -> Result<CoapResponse>

Execute a single post request with a coap url

source

pub fn put(url: &str, data: Vec<u8>) -> Result<CoapResponse>

Execute a put request with a coap url

source

pub fn put_with_timeout( url: &str, data: Vec<u8>, timeout: Duration ) -> Result<CoapResponse>

Execute a single put request with a coap url

source

pub fn delete(url: &str) -> Result<CoapResponse>

Execute a single delete request with a coap url

source

pub fn delete_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>

Execute a single delete request with a coap url

source

pub fn request( url: &str, method: Method, data: Option<Vec<u8>> ) -> Result<CoapResponse>

Execute a single request (GET, POST, PUT, DELETE) with a coap url

source

pub fn request_with_timeout( url: &str, method: Method, data: Option<Vec<u8>>, timeout: Duration ) -> Result<CoapResponse>

Execute a single request (GET, POST, PUT, DELETE) with a coap url and a specfic timeout

source

pub fn request_path( &mut self, path: &str, method: Method, data: Option<Vec<u8>>, queries: Option<Vec<u8>>, domain: Option<String> ) -> Result<CoapResponse>

Execute a request (GET, POST, PUT, DELETE)

source

pub fn request_path_with_timeout( &mut self, path: &str, method: Method, data: Option<Vec<u8>>, queries: Option<Vec<u8>>, domain: Option<String>, timeout: Duration ) -> Result<CoapResponse>

Execute a request (GET, POST, PUT, DELETE) with a specfic timeout. This method will try to use block1 requests with a block size of 1024 by default.

source

pub fn set_broadcast(&self, value: bool) -> Result<()>

source

pub fn observe<H: FnMut(Packet) + Send + 'static>( &mut self, resource_path: &str, handler: H ) -> Result<()>

source

pub fn observe_with_timeout<H: FnMut(Packet) + Send + 'static>( &mut self, resource_path: &str, handler: H, timeout: Duration ) -> Result<()>

Observe a resource with the handler and specified timeout

source

pub fn unobserve(&mut self)

Stop observing

source

pub fn send(&self, request: &CoapRequest<SocketAddr>) -> Result<()>

Execute a request.

source

pub fn send2(&mut self, request: &mut CoapRequest<SocketAddr>) -> Result<()>

send a request supporting block1 option based on the block size set in the client

source

pub fn send_all_coap( &self, request: &CoapRequest<SocketAddr>, segment: u8 ) -> Result<()>

Send a request to all CoAP devices.

  • IPv4 AllCoAP multicast address is ‘224.0.1.187’
  • IPv6 AllCoAp multicast addresses are ‘ff0?::fd’ Parameter segment is used with IPv6 to determine the first octet. It’s value can be between 0x0 and 0xf. To address multiple segments, you have to call send_all_coap for each of the segments.
source

pub fn receive(&self) -> Result<CoapResponse>

Receive a response.

source

pub fn receive2( &mut self, request: &mut CoapRequest<SocketAddr> ) -> Result<CoapResponse>

Receive a response support block-wise.

source

pub fn receive_from(&self) -> Result<(CoapResponse, SocketAddr)>

Receive a response.

source

pub fn set_receive_timeout(&self, dur: Option<Duration>) -> Result<()>

Set the receive timeout.

source

pub fn set_block1_size(&mut self, block1_max_bytes: usize)

Set the maximum size for a block1 request. Default is 1024 bytes

Trait Implementations§

source§

impl Drop for CoAPClient

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.