Struct coap::client::CoAPClient
source · pub struct CoAPClient { /* private fields */ }Implementations§
source§impl CoAPClient
impl CoAPClient
sourcepub fn new_with_specific_source<A: ToSocketAddrs, B: ToSocketAddrs>(
bind_addr: A,
peer_addr: B
) -> Result<CoAPClient>
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.
sourcepub fn new<A: ToSocketAddrs>(addr: A) -> Result<CoAPClient>
pub fn new<A: ToSocketAddrs>(addr: A) -> Result<CoAPClient>
Create a CoAP client with the peer address.
sourcepub fn get(url: &str) -> Result<CoapResponse>
pub fn get(url: &str) -> Result<CoapResponse>
Execute a single get request with a coap url
sourcepub fn get_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>
pub fn get_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>
Execute a single get request with a coap url and a specific timeout.
sourcepub fn post(url: &str, data: Vec<u8>) -> Result<CoapResponse>
pub fn post(url: &str, data: Vec<u8>) -> Result<CoapResponse>
Execute a single post request with a coap url
sourcepub fn post_with_timeout(
url: &str,
data: Vec<u8>,
timeout: Duration
) -> Result<CoapResponse>
pub fn post_with_timeout( url: &str, data: Vec<u8>, timeout: Duration ) -> Result<CoapResponse>
Execute a single post request with a coap url
sourcepub fn put(url: &str, data: Vec<u8>) -> Result<CoapResponse>
pub fn put(url: &str, data: Vec<u8>) -> Result<CoapResponse>
Execute a put request with a coap url
sourcepub fn put_with_timeout(
url: &str,
data: Vec<u8>,
timeout: Duration
) -> Result<CoapResponse>
pub fn put_with_timeout( url: &str, data: Vec<u8>, timeout: Duration ) -> Result<CoapResponse>
Execute a single put request with a coap url
sourcepub fn delete(url: &str) -> Result<CoapResponse>
pub fn delete(url: &str) -> Result<CoapResponse>
Execute a single delete request with a coap url
sourcepub fn delete_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>
pub fn delete_with_timeout(url: &str, timeout: Duration) -> Result<CoapResponse>
Execute a single delete request with a coap url
sourcepub fn request(
url: &str,
method: Method,
data: Option<Vec<u8>>
) -> Result<CoapResponse>
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
sourcepub fn request_with_timeout(
url: &str,
method: Method,
data: Option<Vec<u8>>,
timeout: Duration
) -> Result<CoapResponse>
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
sourcepub fn request_path(
&mut self,
path: &str,
method: Method,
data: Option<Vec<u8>>,
queries: Option<Vec<u8>>,
domain: Option<String>
) -> Result<CoapResponse>
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)
sourcepub 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>
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.
pub fn set_broadcast(&self, value: bool) -> Result<()>
pub fn observe<H: FnMut(Packet) + Send + 'static>( &mut self, resource_path: &str, handler: H ) -> Result<()>
sourcepub fn observe_with_timeout<H: FnMut(Packet) + Send + 'static>(
&mut self,
resource_path: &str,
handler: H,
timeout: Duration
) -> Result<()>
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
sourcepub fn send(&self, request: &CoapRequest<SocketAddr>) -> Result<()>
pub fn send(&self, request: &CoapRequest<SocketAddr>) -> Result<()>
Execute a request.
sourcepub fn send2(&mut self, request: &mut CoapRequest<SocketAddr>) -> Result<()>
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
sourcepub fn send_all_coap(
&self,
request: &CoapRequest<SocketAddr>,
segment: u8
) -> Result<()>
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.
sourcepub fn receive(&self) -> Result<CoapResponse>
pub fn receive(&self) -> Result<CoapResponse>
Receive a response.
sourcepub fn receive2(
&mut self,
request: &mut CoapRequest<SocketAddr>
) -> Result<CoapResponse>
pub fn receive2( &mut self, request: &mut CoapRequest<SocketAddr> ) -> Result<CoapResponse>
Receive a response support block-wise.
sourcepub fn receive_from(&self) -> Result<(CoapResponse, SocketAddr)>
pub fn receive_from(&self) -> Result<(CoapResponse, SocketAddr)>
Receive a response.
sourcepub fn set_receive_timeout(&self, dur: Option<Duration>) -> Result<()>
pub fn set_receive_timeout(&self, dur: Option<Duration>) -> Result<()>
Set the receive timeout.
sourcepub fn set_block1_size(&mut self, block1_max_bytes: usize)
pub fn set_block1_size(&mut self, block1_max_bytes: usize)
Set the maximum size for a block1 request. Default is 1024 bytes