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