pub struct SaulHandler {
prefix: &'static [&'static str],
}
saul
only.Expand description
A handler for SAUL requests, using SAUL_MATCH_SUBTREE to manage its resources.
The path this is registered at must be passed in as the prefix, as link-format responses necessitate knowing one’s own path, and the prefix needs to be stripped off when processing the Uri-Path options.
As the link-format handler is bad, the name must be simple.
Fields§
§prefix: &'static [&'static str]
Implementations§
source§impl SaulHandler
impl SaulHandler
sourcepub fn new(prefix: &'static [&'static str]) -> Self
pub fn new(prefix: &'static [&'static str]) -> Self
Create a SaulHandler
The prefix needs to be passed in in order to produce proper link-format responses which can not be path-relative, and should thus be equal to the prefix assigned in the tree.
fn put_value( &self, entry: RegistryEntry, content_format: ContentFormat, body: &[u8], ) -> Result<(), Error>
Trait Implementations§
source§impl Handler for SaulHandler
impl Handler for SaulHandler
source§type RequestData = SaulRequest
type RequestData = SaulRequest
source§type ExtractRequestError = Error
type ExtractRequestError = Error
extract_request_data()
. Read moresource§type BuildResponseError<M: MinimalWritableMessage> = Error
type BuildResponseError<M: MinimalWritableMessage> = Error
source§fn extract_request_data<M: ReadableMessage>(
&mut self,
request: &M,
) -> Result<SaulRequest, Error>
fn extract_request_data<M: ReadableMessage>( &mut self, request: &M, ) -> Result<SaulRequest, Error>
source§fn estimate_length(&mut self, _: &<Self as Handler>::RequestData) -> usize
fn estimate_length(&mut self, _: &<Self as Handler>::RequestData) -> usize
source§fn build_response<M: MutableWritableMessage>(
&mut self,
response: &mut M,
request: Self::RequestData,
) -> Result<(), Self::BuildResponseError<M>>
fn build_response<M: MutableWritableMessage>( &mut self, response: &mut M, request: Self::RequestData, ) -> Result<(), Self::BuildResponseError<M>>
source§impl Reporting for SaulHandler
impl Reporting for SaulHandler
A SaulHandler lists all its SAUL devices in /.well-known/core. This is especially useful when registering at a Resource Directory using simple registration and lookup clients try to discover sensors.
type Record<'res> = Record
type Reporter<'res> = Chain<Once<Record>, Map<Filter<Enumerate<MapWhile<Map<RangeFrom<usize>, fn(_: usize) -> Option<RegistryEntry>>, fn(_: Option<RegistryEntry>) -> Option<RegistryEntry>>>, fn(_: &(usize, RegistryEntry)) -> bool>, fn(_: (usize, RegistryEntry)) -> Record>>
fn report(&self) -> Self::Reporter<'_>
Auto Trait Implementations§
impl Freeze for SaulHandler
impl RefUnwindSafe for SaulHandler
impl Send for SaulHandler
impl Sync for SaulHandler
impl Unpin for SaulHandler
impl UnwindSafe for SaulHandler
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<'a, OldRD, OldH> HandlerBuilder<'a, OldRD> for OldHwhere
OldH: Handler<RequestData = OldRD>,
impl<'a, OldRD, OldH> HandlerBuilder<'a, OldRD> for OldHwhere
OldH: Handler<RequestData = OldRD>,
source§fn at<H>(self, path: &'a [&'a str], handler: H) -> ForkingHandler<'a, H, Self>where
H: Handler,
fn at<H>(self, path: &'a [&'a str], handler: H) -> ForkingHandler<'a, H, Self>where
H: Handler,
source§fn at_with_attributes<H>(
self,
path: &'a [&'a str],
attributes: &'a [Attribute],
handler: H,
) -> ForkingHandler<'a, ConstantSingleRecordReport<'a, H>, Self>where
H: Handler,
fn at_with_attributes<H>(
self,
path: &'a [&'a str],
attributes: &'a [Attribute],
handler: H,
) -> ForkingHandler<'a, ConstantSingleRecordReport<'a, H>, Self>where
H: Handler,
path
into the given handler
, and announce them with the
given attributes in .well-known/core. Read moresource§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,
source§impl<'a, OldRD, OldH> ReportingHandlerBuilder<'a, OldRD> for OldH
impl<'a, OldRD, OldH> ReportingHandlerBuilder<'a, OldRD> for OldH
source§fn with_wkc(self) -> WellKnownCore<Self>
fn with_wkc(self) -> WellKnownCore<Self>
/.well-known/core
resource that exposes the information the previous (stack of)
handler(s) exposes throught the Reporting trait.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: 8 bytes