ResourceBuilder

Struct ResourceBuilder 

Source
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>

Source

pub fn new(path: &str) -> Self

Source

pub fn not_discoverable(self) -> Self

Source

pub fn disable_block_transfer(self) -> Self

Add a new attribute to the CoRE Link response, assuming that this resource will be discoverable. For more information, see RFC 5785

Source

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”.

Source

pub fn get(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self

Set a request handler for “Get” requests.

Source

pub fn post(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self

Set a request handler for “Post” requests.

Source

pub fn put(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self

Set a request handler for “Put” requests.

Source

pub fn delete( self, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self

Set a request handler for “Delete” requests.

Source

pub fn fetch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self

Set a request handler for “Fetch” requests.

Source

pub fn patch(self, handler: impl RequestHandler<Endpoint> + Send + Sync) -> Self

Set a request handler for “Patch” requests.

Source

pub fn ipatch( self, handler: impl RequestHandler<Endpoint> + Send + Sync, ) -> Self

Set a request handler for “iPatch” requests.

Source

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.

Source

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

Auto Trait Implementations§

§

impl<Endpoint> Freeze for ResourceBuilder<Endpoint>

§

impl<Endpoint> !RefUnwindSafe for ResourceBuilder<Endpoint>

§

impl<Endpoint> !Send for ResourceBuilder<Endpoint>

§

impl<Endpoint> !Sync for ResourceBuilder<Endpoint>

§

impl<Endpoint> Unpin for ResourceBuilder<Endpoint>

§

impl<Endpoint> !UnwindSafe for ResourceBuilder<Endpoint>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V