Struct Client

Source
pub struct Client<E, T: Backend<E>> { /* private fields */ }
Expand description

Async CoAP client, generic over Backend implementations

Implementations§

Source§

impl Client<Error, Tokio>

Source

pub async fn connect<H>(host: H, opts: &ClientOptions) -> Result<Self, Error>

Create a new client with the provided host and client options

Source

pub async fn close(self) -> Result<(), Error>

Close the provided client, ending all existing sessions

Source§

impl<E, T> Client<E, T>
where T: Backend<E>, E: Debug,

Source

pub async fn request( &mut self, method: Method, resource: &str, data: Option<&[u8]>, opts: &RequestOptions, ) -> Result<Packet, Error<E>>

Perform a basic CoAP request

Source

pub async fn observe( &mut self, resource: &str, opts: &RequestOptions, ) -> Result<<T as Backend<E>>::Observe, E>

Observe the provided resource

Source

pub async fn unobserve( &mut self, o: <T as Backend<E>>::Observe, ) -> Result<(), E>

Deregister an observation

Source

pub async fn get( &mut self, resource: &str, opts: &RequestOptions, ) -> Result<Vec<u8>, Error<E>>

Perform a Get request from the provided resource

Source

pub async fn put( &mut self, resource: &str, data: Option<&[u8]>, opts: &RequestOptions, ) -> Result<Vec<u8>, Error<E>>

Perform a Put request to the provided resource

Source

pub async fn post( &mut self, resource: &str, data: Option<&[u8]>, opts: &RequestOptions, ) -> Result<Vec<u8>, Error<E>>

Perform a Post request to the provided resource

Trait Implementations§

Source§

impl<E, B: Backend<E> + Send> Send for Client<E, B>

Mark clients as Send if the backend is

Auto Trait Implementations§

§

impl<E, T> Freeze for Client<E, T>
where T: Freeze,

§

impl<E, T> RefUnwindSafe for Client<E, T>

§

impl<E, T> Sync for Client<E, T>
where T: Sync, E: Sync,

§

impl<E, T> Unpin for Client<E, T>
where T: Unpin, E: Unpin,

§

impl<E, T> UnwindSafe for Client<E, T>
where T: UnwindSafe, E: UnwindSafe,

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V