pub struct Write<P: Key> { /* private fields */ }
Expand description
Middleware for data that persists between Requests for data which mostly needs to be written instead of read.
The data is stored behind a Mutex
, so only one request at a time can
access the data. This is more performant than State
in the case where
most uses of the data require a write lock.
Write
can be linked as BeforeMiddleware
to add data to the Request
extensions and it can be linked as an AfterMiddleware
to add data to
the Response
extensions.
Write
also implements Plugin
, so the data stored within can be
accessed through request.get::<Write<P>>()
as an Arc<Mutex<P::Value>>
.
Implementations§
Trait Implementations§
Source§impl<P: Key> AfterMiddleware for Write<P>
impl<P: Key> AfterMiddleware for Write<P>
Source§impl<P: Key> BeforeMiddleware for Write<P>
impl<P: Key> BeforeMiddleware for Write<P>
Auto Trait Implementations§
impl<P> Freeze for Write<P>
impl<P> RefUnwindSafe for Write<P>
impl<P> Send for Write<P>
impl<P> Sync for Write<P>
impl<P> Unpin for Write<P>
impl<P> UnwindSafe for Write<P>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PersistentInto<Arc<Mutex<T>>> for T
impl<T> PersistentInto<Arc<Mutex<T>>> for T
Source§fn persistent_into(self) -> Arc<Mutex<T>>
fn persistent_into(self) -> Arc<Mutex<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<RwLock<T>>> for T
impl<T> PersistentInto<Arc<RwLock<T>>> for T
Source§fn persistent_into(self) -> Arc<RwLock<T>>
fn persistent_into(self) -> Arc<RwLock<T>>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<Arc<T>> for T
impl<T> PersistentInto<Arc<T>> for T
Source§fn persistent_into(self) -> Arc<T>
fn persistent_into(self) -> Arc<T>
Convert
self
into a value of type T
.Source§impl<T> PersistentInto<T> for T
impl<T> PersistentInto<T> for T
Source§fn persistent_into(self) -> T
fn persistent_into(self) -> T
Convert
self
into a value of type T
.