pub struct TryingThroughMutex<T: TypeRenderable>(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: TypeRenderable> TypeRenderable for TryingThroughMutex<T>

§

type Get = <T as TypeRenderable>::Get

§

type Put = <T as TypeRenderable>::Put

§

type Post = <T as TypeRenderable>::Post

source§

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

source§

fn put(&mut self, new: &Self::Put) -> u8

source§

fn post(&mut self, request: &Self::Post) -> u8

source§

fn delete(&mut self) -> u8

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.