Skip to main content

ExternalStoreRuntime

Struct ExternalStoreRuntime 

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

A thread whose messages the app owns.

Implementations§

Source§

impl ExternalStoreRuntime

Source

pub fn new(store: impl ExternalStore + 'static) -> Self

A runtime over store, with no messages yet.

Source

pub fn subscribe(&self, callback: impl Fn() + 'static) -> Subscription

Called after every change. Drop the guard to unsubscribe.

Source

pub fn set_messages<M: Into<Arc<ThreadMessage>>>( &self, messages: impl IntoIterator<Item = M>, )

The app’s current messages as a linear history (messages). Messages equal to what is already shown keep their Arc.

Source

pub fn set_repository(&self, exported: ExportedRepository)

The app’s messages with branches (messageRepository).

Source

pub fn set_running(&self, running: bool)

Tell the runtime whether the app is generating a response.

Source

pub fn set_disabled(&self, disabled: bool)

Disable sending (for example while the app is offline).

Trait Implementations§

Source§

impl Clone for ExternalStoreRuntime

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ThreadRuntime for ExternalStoreRuntime

Source§

fn messages(&self) -> Arc<[Arc<ThreadMessage>]> ⓘ

The selected branch, root first.
Source§

fn message(&self, id: &MessageId) -> Result<MessageEntry, RuntimeError>

A message and its position, by id.
Source§

fn is_running(&self) -> bool

Whether a run is in progress.
Source§

fn capabilities(&self) -> RuntimeCapabilities

What the UI may offer for this thread.
Source§

fn branches(&self, id: &MessageId) -> Result<Vec<MessageId>, RuntimeError>

The message and its siblings.
Source§

fn branch_position( &self, id: &MessageId, ) -> Result<(usize, usize), RuntimeError>

(position, count) of the message among its siblings, 1-based. The default builds branches; runtimes override it to avoid the allocation, which a UI pays once per message per update.
Source§

fn switch_to_branch(&self, id: &MessageId) -> Result<(), RuntimeError>

Select the branch containing id.
Source§

fn append(&self, message: AppendMessage) -> Result<RunFuture, RuntimeError>

Add a message; a user message answers it (see AppendMessage).
Source§

fn reload(&self, config: StartRunConfig) -> Result<RunFuture, RuntimeError>

Answer parent_id again (regenerate).
Source§

fn cancel_run(&self)

Stop the run in progress, if any.
Source§

fn add_tool_result( &self, result: ToolResult, ) -> Result<Option<RunFuture>, RuntimeError>

Answer a tool call; may resume the run, which is then returned to spawn.
Source§

fn respond_to_tool_approval( &self, message_id: &MessageId, approval_id: &str, approved: bool, reason: Option<String>, ) -> Result<Option<RunFuture>, RuntimeError>

Approve or deny a pending tool approval; may resume the run, which is then returned to spawn.
Source§

fn submit_feedback( &self, id: &MessageId, feedback: Option<SubmittedFeedback>, ) -> Result<(), RuntimeError>

None clears feedback.
Source§

fn composer(&self) -> Composer

The composer for the next message.
Source§

fn begin_edit(&self, id: &MessageId) -> Result<Composer, RuntimeError>

Start editing a message and return its composer.
Source§

fn edit_composer(&self, id: &MessageId) -> Option<Composer>

The composer of a message being edited, if any.
Source§

fn subscribe_dyn(&self, callback: Box<dyn Fn()>) -> Subscription

Called after every change; drop the guard to unsubscribe.
Source§

fn export(&self) -> ExportedRepository

Persisted messages and the selected head.
Source§

fn import(&self, exported: ExportedRepository) -> Result<(), RuntimeError>

Load history.
Source§

fn structure_version(&self) -> Option<u64>

A number that changes whenever branches or the selected path change, but not when a message is updated in place. While it is unchanged a UI may keep every message’s branch_position. None (the default) means unknown: positions must be read again.
Source§

fn message_changes_since(&self, _version: Option<u64>) -> Option<MessageChanges>

Changed selected-message indices since a consumer’s last version. None (the default) means this runtime does not track changes: scan messages. A supported runtime returns a current version even when the journal requires a full read. Changes must cover every selected message update and be valid for the current messages() snapshot; versions are local to this runtime. Consumers must still refresh when running state or capabilities change.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.