Skip to main content

RuntimeSessionAdapter

Struct RuntimeSessionAdapter 

Source
pub struct RuntimeSessionAdapter { /* private fields */ }
Expand description

Wraps a SessionService to provide v9 runtime capabilities.

Maintains a per-session RuntimeDriver registry. When sessions are registered with a CoreExecutor, a RuntimeLoop task is spawned that processes queued inputs by calling CoreExecutor::apply() (which triggers SessionService::start_turn() under the hood).

Implementations§

Source§

impl RuntimeSessionAdapter

Source

pub fn ephemeral() -> Self

Create an ephemeral adapter (all sessions use EphemeralRuntimeDriver).

Source

pub fn persistent(store: Arc<dyn RuntimeStore>) -> Self

Create a persistent adapter with a RuntimeStore.

Source

pub async fn register_session(&self, session_id: SessionId)

Register a runtime driver for a session (no RuntimeLoop — inputs queue but nothing processes them automatically). Useful for tests and legacy mode.

Source

pub async fn register_session_with_executor( &self, session_id: SessionId, executor: Box<dyn CoreExecutor>, )

Register a runtime driver for a session WITH a RuntimeLoop backed by a CoreExecutor. When accept_input() queues an input and requests wake, the loop dequeues it and calls executor.apply() (which triggers SessionService::start_turn()).

Source

pub async fn ensure_session_with_executor( &self, session_id: SessionId, executor: Box<dyn CoreExecutor>, )

Ensure a runtime driver with executor exists for the session.

If a session was already registered without a loop, upgrade the existing driver in place so queued inputs remain attached to the same runtime ledger and can start draining immediately.

Source

pub async fn unregister_session(&self, session_id: &SessionId)

Unregister a session’s runtime driver.

Drops the wake channel sender, which causes the RuntimeLoop to exit.

Source

pub async fn contains_session(&self, session_id: &SessionId) -> bool

Check whether a runtime driver is already registered for a session.

Source

pub async fn interrupt_current_run( &self, session_id: &SessionId, ) -> Result<(), RuntimeDriverError>

Cancel the currently-running turn for a registered session.

Source

pub async fn accept_input_and_run<T, F, Fut>( &self, session_id: &SessionId, input: Input, op: F, ) -> Result<T, RuntimeDriverError>
where F: FnOnce(RunId, RunPrimitive) -> Fut, Fut: Future<Output = Result<(T, CoreApplyOutput), RuntimeDriverError>>,

Accept an input and execute it synchronously through the runtime driver.

This is useful for surfaces that need the legacy request/response shape while still preserving v9 input lifecycle semantics.

Source

pub async fn accept_input_with_completion( &self, session_id: &SessionId, input: Input, ) -> Result<(AcceptOutcome, Option<CompletionHandle>), RuntimeDriverError>

Accept an input and return a completion handle that resolves when the input reaches a terminal state (Consumed or Abandoned).

Returns (AcceptOutcome, Option<CompletionHandle>):

  • (Accepted, Some(handle)) — await handle for result
  • (Deduplicated, Some(handle)) — joined in-flight waiter
  • (Deduplicated, None) — input already terminal; no waiter needed
  • (Rejected, _) — returned as Err(ValidationFailed)

Trait Implementations§

Source§

impl SessionServiceRuntimeExt for RuntimeSessionAdapter

Source§

fn runtime_mode(&self) -> RuntimeMode

Get the runtime mode.
Source§

fn accept_input<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, input: Input, ) -> Pin<Box<dyn Future<Output = Result<AcceptOutcome, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Accept an input for a session.
Source§

fn runtime_state<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<RuntimeState, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the runtime state for a session.
Source§

fn retire_runtime<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<RetireReport, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retire a session’s runtime.
Source§

fn reset_runtime<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<ResetReport, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reset a session’s runtime.
Source§

fn input_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, input_id: &'life2 InputId, ) -> Pin<Box<dyn Future<Output = Result<Option<InputState>, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get the state of a specific input.
Source§

fn list_active_inputs<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<InputId>, RuntimeDriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all active (non-terminal) inputs for a session.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more