Skip to main content

Session

Struct Session 

Source
pub struct Session<'scope, 'd: 'scope, S = (), Q = ()> { /* private fields */ }

Implementations§

Source§

impl<'scope, 'd: 'scope, S, Q> Session<'scope, 'd, S, Q>

Source

pub fn storage(&self) -> &'d S
where S: 'd,

Storage for the complete driver domain. Its domain lifetime is independent of the temporary session borrow.

Source

pub fn driver_access(&mut self) -> Context<'_, 'd>

Returns the session’s exclusive driver context for staging resources.

The access lifetime is tied to this mutable session borrow. Consequently the context cannot escape the generative executor scope, overlap another driver context, or coexist with an installed application.

ⓘ
use dope_core::driver;
use dope_runtime::executor::Executor;

fn escape(executor: Executor) -> driver::Context<'static, 'static> {
    executor.enter(|mut session| session.driver_access())
}
ⓘ
use dope_runtime::executor::{self, Application};

fn overlap<'scope, 'd, D>(
    session: &mut executor::session::Session<'scope, 'd>,
    app: D,
) where
    'd: 'scope,
    D: Application<'d>,
{
    let driver = session.driver_access();
    let _ = session.with_app(app, |_| {});
    drop(driver);
}
ⓘ
use dope_runtime::executor::session::Session;

fn duplicate<'scope, 'd>(session: &mut Session<'scope, 'd>)
where
    'd: 'scope,
{
    let first = session.driver_access();
    let second = session.driver_access();
    drop((first, second));
}
Source

pub fn hash_state(&mut self, domain: Domain) -> HashState<'d>

Issues a keyed hash builder bound to this exact driver domain.

ⓘ
use dope_runtime::{
    executor::Executor,
    random::{Domain, HashState},
};

fn escape(executor: Executor) -> HashState<'static> {
    executor.enter(|mut session| session.hash_state(Domain::new(0)))
}
Source

pub fn with_app<D, R>( &mut self, app: D, f: impl for<'app> FnOnce(Application<'app, 'd, D, Q>) -> R, ) -> Result<R>
where D: Application<'d>, Q: Startup,

Installs one application for f and finalizes it on normal return.

§Panics

Application or callback panics are terminal; session reuse is not guaranteed.

Source

pub fn with_provider<O, P, C>( &mut self, owner: O, select: impl for<'borrow> FnOnce(Pin<&'borrow O>) -> Pin<&'borrow P>, composition: C, ) -> C::Output
where P: Provider<'d>, C: Composition<'scope, 'd, S, Q, O, P>,

Runs a composition with a pinned provider owner and its scoped client. The higher-ranked application lifetime prevents either from escaping.

Auto Trait Implementations§

§

impl<'scope, 'd, S = (), Q = ()> !RefUnwindSafe for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S = (), Q = ()> !Send for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S = (), Q = ()> !Sync for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S = (), Q = ()> !UnwindSafe for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S, Q> Freeze for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S, Q> Unpin for Session<'scope, 'd, S, Q>

§

impl<'scope, 'd, S, Q> UnsafeUnpin for Session<'scope, 'd, S, Q>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.