Struct libcoap_rs::CoapResource
source · Expand description
Representation of a CoapResource that can be requested from a server.
Implementations
sourceimpl<D: Any + ?Sized + Debug> CoapResource<D>
impl<D: Any + ?Sized + Debug> CoapResource<D>
sourcepub fn new<C: Into<Box<D>>>(
uri_path: &str,
user_data: C,
notify_con: bool
) -> CoapResource<D>
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.
sourcepub fn notify_observers(&self) -> bool
pub fn notify_observers(&self) -> bool
Notify any observers about changes to this resource.
sourcepub fn set_get_observable(&self, observable: bool)
pub fn set_get_observable(&self, observable: bool)
Sets whether this resource can be observed by clients according to RFC 7641.
sourcepub fn set_observe_notify_confirmable(&self, confirmable: bool)
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.
sourcepub fn user_data_mut(&self) -> RefMut<'_, D>
pub fn user_data_mut(&self) -> RefMut<'_, D>
Mutably returns the user data associated with this resource.
sourcepub unsafe fn restore_from_raw(
raw_resource: *mut coap_resource_t
) -> CoapResource<D>
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.
sourcepub fn set_method_handler<H: Into<CoapRequestHandler<D>>>(
&self,
code: CoapRequestCode,
handler: Option<H>
)
pub fn set_method_handler<H: Into<CoapRequestHandler<D>>>(
&self,
code: CoapRequestCode,
handler: Option<H>
)
Sets the handler function for a given method code.