pub struct SingleHandlerListener<'a, H> {
_phantom: PhantomData<&'a H>,
resource: coap_resource_t,
listener: gcoap_listener_t,
}
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) })
.
Fields§
§_phantom: PhantomData<&'a H>
§resource: coap_resource_t
§listener: gcoap_listener_t
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
fn _new( path: &'a CStr, methods: u32, handler: &'a mut H, encoder: Option<unsafe extern "C" fn(_: *const coap_resource_t, _: *mut c_char, _: size_t, _: *mut coap_link_encoder_ctx_t) -> ssize_t>, ) -> 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_0_2::Handler, you can wrap it in crate::coap_handler::v0_2::GcoapHandler to for adaptation.
unsafe extern "C" fn call_handler( pkt: *mut coap_pkt_t, buf: *mut u8, len: size_t, context: *mut coap_request_ctx_t, ) -> ssize_t
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.
Trait Implementations§
Source§impl<'a, H> ListenerProvider for SingleHandlerListener<'a, H>where
H: 'a + Handler,
impl<'a, H> ListenerProvider for SingleHandlerListener<'a, H>where
H: 'a + Handler,
Source§unsafe fn get_listener(&mut self) -> &mut gcoap_listener_t
unsafe fn get_listener(&mut self) -> &mut gcoap_listener_t
Auto Trait Implementations§
impl<'a, H> Freeze for SingleHandlerListener<'a, H>
impl<'a, H> RefUnwindSafe for SingleHandlerListener<'a, H>where
H: RefUnwindSafe,
impl<'a, H> !Send for SingleHandlerListener<'a, H>
impl<'a, H> !Sync for SingleHandlerListener<'a, H>
impl<'a, H> Unpin for SingleHandlerListener<'a, H>
impl<'a, H> UnwindSafe for SingleHandlerListener<'a, H>where
H: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoSwitch for T
impl<T> IntoSwitch for T
Source§fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
Source§fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes