pub trait SessionExt: Sized + Sealed {
// Required methods
fn session(&self) -> VortexSession;
fn get<V: VortexSessionVar + Default>(&self) -> SessionGuard<'_, V>;
fn get_opt<V: VortexSessionVar>(&self) -> Option<SessionGuard<'_, V>>;
fn get_mut<V: VortexSessionVar + Default + Clone>(
&self,
) -> SessionMut<'_, V>;
}Expand description
Trait for accessing the state of a Vortex session.
Required Methods§
Sourcefn session(&self) -> VortexSession
fn session(&self) -> VortexSession
Returns the VortexSession.
Sourcefn get<V: VortexSessionVar + Default>(&self) -> SessionGuard<'_, V>
fn get<V: VortexSessionVar + Default>(&self) -> SessionGuard<'_, V>
Returns the session variable of type V, inserting a default one if it does not exist.
The default is constructed and inserted copy-on-write: V::default() runs without any lock
held, so it may freely re-enter the session, and a concurrent insert of the same type is
resolved by keeping the first value published.
Sourcefn get_opt<V: VortexSessionVar>(&self) -> Option<SessionGuard<'_, V>>
fn get_opt<V: VortexSessionVar>(&self) -> Option<SessionGuard<'_, V>>
Returns the session variable of type V if it exists.
Sourcefn get_mut<V: VortexSessionVar + Default + Clone>(&self) -> SessionMut<'_, V>
fn get_mut<V: VortexSessionVar + Default + Clone>(&self) -> SessionMut<'_, V>
Returns a copy-on-write SessionMut handle for the variable of type V, inserting a
default one first if it does not exist.
The handle starts as a clone of the current value; mutating it through DerefMut and
dropping it publishes the result back into the session copy-on-write — the ergonomic
equivalent of reading the variable, modifying a clone, and re-inserting it into the session.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".