Struct riot_wrappers::gcoap::SingleHandlerListener
source · pub struct SingleHandlerListener<'a, H> { /* private fields */ }
riot_module_gcoap
only.Expand description
A combination of the coap_resource_t and gcoap_listener_t structs with only a single resource (Compared to many resources, this allows easier creation in Rust at the expense of larger memory consumption and slower lookups in Gcoap).
A listener l
can be hooked into the global Gcoap registry using scope
(|x| { x.
register
(l) })
.
Implementations§
source§impl<'a, H> SingleHandlerListener<'a, H>where
H: 'a + Handler,
impl<'a, H> SingleHandlerListener<'a, H>where
H: 'a + Handler,
pub fn new(path: &'a CStr, methods: u32, handler: &'a mut H) -> Self
sourcepub fn new_catch_all(handler: &'a mut H) -> Self
pub fn new_catch_all(handler: &'a mut H) -> Self
Create a listener whose single resource catches all requests and processes them through the handler.
This is equivalent to a new single listener at “/” that takes all methods and matches on subtrees.
Note that the taken Handler is a Gcoap Handler (which is there really only in case anyone wants extremely fine-grained control of what gcoap does); if you have a [coap_handler::Handler], you can wrap it in crate::coap_handler::GcoapHandler to for adaptation.
source§impl<'a, H> SingleHandlerListener<'a, H>where
H: 'a + Handler + WithLinkEncoder,
impl<'a, H> SingleHandlerListener<'a, H>where
H: 'a + Handler + WithLinkEncoder,
sourcepub fn new_with_link_encoder(
path: &'a CStr,
methods: u32,
handler: &'a mut H
) -> Self
pub fn new_with_link_encoder( path: &'a CStr, methods: u32, handler: &'a mut H ) -> Self
Like Self::new()
, but utilizing that the handler is also WithLinkEncoder and can thus influence
what is reported when the default .well-known/core handler is queried.