TryingThroughMutex

Struct TryingThroughMutex 

Source
pub struct TryingThroughMutex<T>(pub Arc<Mutex<T>>);
Expand description

Helper struct that accesses a TypeRenderable intrough an Arc<Mutex<_>>, thus allowing easiy simultaneous access.

When implementing SimpelCBORHandler, it does not wait for the lock, but rather fails with a 5.03 Service Unavailable that usually prompts the client to retry. Note that this will not happen ever if the items are just accessed through different paths on the same handler, and neither will be if they are only ever locked outside the CoAP server’s main loop. (And even then, unless they’re locked for long, it’s very unlikely to be hit by chance).

TBD: Send a “Max-Age: 0” option along to indicate that the client can try again right away rather than wait the usual 60 seconds.

TBD: This may be a nice addition to the coap_handler crate in general (but needs the introduction of a std feature there).

Tuple Fields§

§0: Arc<Mutex<T>>

Trait Implementations§

Source§

impl<T: DeleteRenderable> DeleteRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

fn delete(&mut self) -> Result<(), Error>

Source§

impl<T: FetchRenderable> FetchRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

type FetchIn = <T as FetchRenderable>::FetchIn

Input type of the fetch() method, deserialized from the request payload. Read more
Source§

type FetchOut = <T as FetchRenderable>::FetchOut

Ouptut type of the fetch() method, serialized into the response payload.
Source§

fn fetch(&mut self, request: &Self::FetchIn) -> Result<Self::FetchOut, Error>

Source§

impl<T: GetRenderable> GetRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

type Get = <T as GetRenderable>::Get

Output type of the get() method, serialized into the response payload.
Source§

fn get(&mut self) -> Result<Self::Get, Error>

Source§

impl<T: IPatchRenderable> IPatchRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

type IPatch = <T as IPatchRenderable>::IPatch

Input type of the ipatch() method, deserialized from the request payload.
Source§

fn ipatch(&mut self, new: &Self::IPatch) -> Result<(), Error>

Source§

impl<T: PostRenderable> PostRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

type PostIn = <T as PostRenderable>::PostIn

Input type of the post() method, deserialized from the request payload.
Source§

type PostOut = <T as PostRenderable>::PostOut

Ouptut type of the post() method, serialized into the response payload. Read more
Source§

fn post(&mut self, request: &Self::PostIn) -> Result<Self::PostOut, Error>

Source§

impl<T: PutRenderable> PutRenderable for TryingThroughMutex<T>

Available on crate feature std only.
Source§

type Put = <T as PutRenderable>::Put

Input type of the put() method, deserialized from the request payload.
Source§

fn put(&mut self, new: &Self::Put) -> Result<(), Error>

Source§

impl<T: TypeRenderable> TypeRenderable for TryingThroughMutex<T>

Available on crate feature std only.

Auto Trait Implementations§

§

impl<T> Freeze for TryingThroughMutex<T>

§

impl<T> RefUnwindSafe for TryingThroughMutex<T>

§

impl<T> Send for TryingThroughMutex<T>
where T: Send,

§

impl<T> Sync for TryingThroughMutex<T>
where T: Send,

§

impl<T> Unpin for TryingThroughMutex<T>

§

impl<T> UnwindSafe for TryingThroughMutex<T>

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> Same for T

Source§

type Output = T

Should always be Self
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.