Struct CoapResource

Source
pub struct CoapResource<D: Any + ?Sized + Debug> { /* private fields */ }
Expand description

Representation of a CoapResource that can be requested from a server.

Implementations§

Source§

impl<D: Any + ?Sized + Debug> CoapResource<D>

Source

pub fn new<C: Into<Box<D>>>( uri_path: &str, user_data: C, notify_con: bool, ) -> CoapResource<D>

Creates a new CoapResource for the given uri_path.

Handlers that are associated with this resource have to be able to take a reference to the provided user_data value as their first value.

The notify_con parameter specifies whether observe notifications originating from this resource are sent as confirmable or non-confirmable.

Source

pub fn notify_observers(&self) -> bool

Notify any observers about changes to this resource.

Source

pub fn set_get_observable(&self, observable: bool)

Sets whether this resource can be observed by clients according to RFC 7641.

Source

pub fn set_observe_notify_confirmable(&self, confirmable: bool)

Sets whether observe notifications for this resource should be sent as confirmable or non-confirmable CoAP messages.

Source

pub fn user_data(&self) -> Ref<'_, D>

Returns the user data associated with this resource.

Source

pub fn user_data_mut(&self) -> RefMut<'_, D>

Mutably returns the user data associated with this resource.

Source

pub unsafe fn restore_from_raw( raw_resource: *mut coap_resource_t, ) -> CoapResource<D>

Restores a resource from its raw coap_resource_t.

§Safety

The supplied pointer must point to a valid coap_resource_t instance that has a Rc<RefCell<CoapResourceInner<D>>> as its user data.

Source

pub fn set_method_handler<H: Into<CoapRequestHandler<D>>>( &self, code: CoapRequestCode, handler: Option<H>, )

Sets the handler function for a given method code.

Trait Implementations§

Source§

impl<D: Debug + Any + ?Sized + Debug> Debug for CoapResource<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for CoapResource<D>
where D: ?Sized,

§

impl<D> !RefUnwindSafe for CoapResource<D>

§

impl<D> !Send for CoapResource<D>

§

impl<D> !Sync for CoapResource<D>

§

impl<D> Unpin for CoapResource<D>
where D: ?Sized,

§

impl<D> !UnwindSafe for CoapResource<D>

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

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

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T