pub struct ResourceBuilder<Endpoint: Ord + Clone> { /* private fields */ }Expand description
Configure a specific resource handler, potentially with distinct per-method handlers.
Implementations§
Source§impl<Endpoint: Debug + Clone + Eq + Hash + Ord + Send + 'static> ResourceBuilder<Endpoint>
impl<Endpoint: Debug + Clone + Eq + Hash + Ord + Send + 'static> ResourceBuilder<Endpoint>
pub fn new(path: &str) -> Self
Sourcepub fn not_discoverable(self) -> Self
pub fn not_discoverable(self) -> Self
Sourcepub fn disable_block_transfer(self) -> Self
pub fn disable_block_transfer(self) -> Self
Sourcepub fn link_attr(
self,
attr_name: &'static str,
value: impl LinkAttributeValue<String> + 'static,
) -> Self
pub fn link_attr( self, attr_name: &'static str, value: impl LinkAttributeValue<String> + 'static, ) -> Self
Add a new attribute to the CoRE Link response, assuming that this resource will be discoverable. For more information, see RFC 5785
Sourcepub fn default_handler(
self,
handler: impl RequestHandler<Endpoint> + Send + Sync,
) -> Self
pub fn default_handler( self, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self
Set a default catch-all handler if another more specific request handler does not match. This can be useful if you wish to override the default behaviour of responding with “4.05 Method not allowed”.
Sourcepub fn get(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
pub fn get(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
Set a request handler for “Get” requests.
Sourcepub fn post(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
pub fn post(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
Set a request handler for “Post” requests.
Sourcepub fn put(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
pub fn put(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
Set a request handler for “Put” requests.
Sourcepub fn delete(
self,
handler: impl RequestHandler<Endpoint> + Send + Sync,
) -> Self
pub fn delete( self, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self
Set a request handler for “Delete” requests.
Sourcepub fn fetch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
pub fn fetch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
Set a request handler for “Fetch” requests.
Sourcepub fn patch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
pub fn patch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self
Set a request handler for “Patch” requests.
Sourcepub fn ipatch(
self,
handler: impl RequestHandler<Endpoint> + Send + Sync,
) -> Self
pub fn ipatch( self, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self
Set a request handler for “iPatch” requests.
Sourcepub fn method_handler(
self,
request_type: RequestType,
handler: impl RequestHandler<Endpoint> + Send + Sync,
) -> Self
pub fn method_handler( self, request_type: RequestType, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self
Set a request handler for arbitrary request types. This method is provided to enable convenient dynamic building of resource handlers, but is not preferred for most applications.
Sourcepub fn observable(
self,
observable: impl ObservableResource + Send + Sync,
) -> Self
pub fn observable( self, observable: impl ObservableResource + Send + Sync, ) -> Self
Enable Observe support for Get and/or Fetch requests in this resource. An observable
argument is required to usefully take advantage of this support which requires
callers to invoke crate::app::Observers::notify_change in order to trigger
updates to be delivered to registered observers.
For more information, see RFC 7641