pub struct Context<'a, E: Executor> {
pub executor: &'a E,
pub id: String,
/* private fields */
}Expand description
Handler context providing access to executor and shared data.
Context wraps an RwContext for type-safe
data storage and provides access to the executor for database operations.
Fields§
§executor: &'a EReference to the executor for database operations
id: StringImplementations§
Source§impl<'a, E: Executor> Context<'a, E>
impl<'a, E: Executor> Context<'a, E>
Sourcepub async fn get_snapshot<D: DecodeOwned + ProjectionCursor>(
&self,
) -> Result<Option<D>>
pub async fn get_snapshot<D: DecodeOwned + ProjectionCursor>( &self, ) -> Result<Option<D>>
Retrieves a stored snapshot for the given ID.
Returns None if no snapshot exists.
Sourcepub async fn take_snapshot<D: Encode + ProjectionCursor>(
&self,
data: &D,
) -> Result<()>
pub async fn take_snapshot<D: Encode + ProjectionCursor>( &self, data: &D, ) -> Result<()>
Stores a snapshot for the given ID.
The snapshot cursor is extracted from the data to track the event position.
Sourcepub async fn drop_snapshot(&self) -> Result<()>
pub async fn drop_snapshot(&self) -> Result<()>
Deletes the stored snapshot for the given ID.
Idempotent: no error if no snapshot exists.
Methods from Deref<Target = RwContext>§
Sourcepub fn insert<T: Send + Sync + 'static>(&self, val: T) -> Option<T>
pub fn insert<T: Send + Sync + 'static>(&self, val: T) -> Option<T>
Insert an item into the map.
If an item of this type was already stored, it will be replaced and returned.
Sourcepub fn extract<T: Clone + 'static>(&self) -> T
pub fn extract<T: Clone + 'static>(&self) -> T
Get a clone of an item of a given type, panics if not found.
Trait Implementations§
Auto Trait Implementations§
impl<'a, E> Freeze for Context<'a, E>
impl<'a, E> RefUnwindSafe for Context<'a, E>where
E: RefUnwindSafe,
impl<'a, E> Send for Context<'a, E>
impl<'a, E> Sync for Context<'a, E>
impl<'a, E> Unpin for Context<'a, E>
impl<'a, E> UnsafeUnpin for Context<'a, E>
impl<'a, E> UnwindSafe for Context<'a, E>where
E: RefUnwindSafe,
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