Skip to main content

CoapPublisher

Struct CoapPublisher 

Source
pub struct CoapPublisher { /* private fields */ }
Expand description

A handle that sets the state of a server’s resources from anywhere, while another task waits on the server’s recv.

A gateway that takes readings in one loop and sends commands from another holds one of these for the commands, since a receive holds the server itself.

Implementations§

Source§

impl CoapPublisher

Source

pub async fn publish(&self, path: &str, payload: &[u8]) -> Result<()>

Sets the state of a resource and notifies every observer of it.

§Arguments
  • path - the resource’s path.
  • payload - its new state, which a GET now reads.
§Returns

Ok(()) once each observer’s notification has left. An observer that has gone does not stop the others’ notifications.

§Errors

Returns [Error::Closed] if the server is not connected, or [Error::Transport] if the socket failed for a reason other than an observer that has gone.

Source

pub fn observers(&self, path: &str) -> usize

Counts the clients observing a resource.

§Arguments
  • path - the resource’s path.
§Returns

How many observers the resource has.

Source

pub fn is_connected(&self) -> bool

Reports whether the server holds a bound socket.

§Returns

true while the server is connected.

Source

pub fn local_addr(&self) -> Option<SocketAddr>

The address the server listens on.

§Returns

The local address, or None while the server is not connected.

Trait Implementations§

Source§

impl Clone for CoapPublisher

Source§

fn clone(&self) -> CoapPublisher

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.