Struct async_recorder::Recorder
source · pub struct Recorder<T: Storage> { /* private fields */ }
Expand description
Persists records asynchronously.
You may want to use this instead of directly calling your persistence backend if you do not want
to wait for the record to be persisted, in the handler which created the record. To achieve this
Recoder spawns an actor to which all records are sent immediatly. The actor when uses the
Storage
trait to talk to your persistence backend.
Recorder takes ownership of an actor and the green thread it is running in.
Implementations§
source§impl<T> Recorder<T>where
T: Storage + 'static + Send,
T::Record: Send,
T::Query: Send,
impl<T> Recorder<T>where T: Storage + 'static + Send, T::Record: Send, T::Query: Send,
pub async fn new(storage: T) -> Self
sourcepub fn save(&self, record: T::Record)
pub fn save(&self, record: T::Record)
Sends the record to the internal actor for storage. This interface is fire and forget. It will not wait for the record to be actually persisted, just place it in the channel for the actor to pick up. This is why this method is both synchronous and non blocking.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Recorder<T>
impl<T> Send for Recorder<T>where T: Send, <T as Storage>::Query: Send, <T as Storage>::Record: Send,
impl<T> Sync for Recorder<T>where T: Send, <T as Storage>::Query: Send, <T as Storage>::Record: Send,
impl<T> Unpin for Recorder<T>
impl<T> !UnwindSafe for Recorder<T>
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