pub struct ExternalStoreRuntime { /* private fields */ }Expand description
A thread whose messages the app owns.
Implementations§
Source§impl ExternalStoreRuntime
impl ExternalStoreRuntime
Sourcepub fn new(store: impl ExternalStore + 'static) -> Self
pub fn new(store: impl ExternalStore + 'static) -> Self
A runtime over store, with no messages yet.
Sourcepub fn subscribe(&self, callback: impl Fn() + 'static) -> Subscription
pub fn subscribe(&self, callback: impl Fn() + 'static) -> Subscription
Called after every change. Drop the guard to unsubscribe.
Sourcepub fn set_messages<M: Into<Arc<ThreadMessage>>>(
&self,
messages: impl IntoIterator<Item = M>,
)
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.
Sourcepub fn set_repository(&self, exported: ExportedRepository)
pub fn set_repository(&self, exported: ExportedRepository)
The app’s messages with branches (messageRepository).
Sourcepub fn set_running(&self, running: bool)
pub fn set_running(&self, running: bool)
Tell the runtime whether the app is generating a response.
Sourcepub fn set_disabled(&self, disabled: bool)
pub fn set_disabled(&self, disabled: bool)
Disable sending (for example while the app is offline).
Trait Implementations§
Source§impl Clone for ExternalStoreRuntime
impl Clone for ExternalStoreRuntime
Source§impl ThreadRuntime for ExternalStoreRuntime
impl ThreadRuntime for ExternalStoreRuntime
Source§fn message(&self, id: &MessageId) -> Result<MessageEntry, RuntimeError>
fn message(&self, id: &MessageId) -> Result<MessageEntry, RuntimeError>
A message and its position, by id.
Source§fn is_running(&self) -> bool
fn is_running(&self) -> bool
Whether a run is in progress.
Source§fn capabilities(&self) -> RuntimeCapabilities
fn capabilities(&self) -> RuntimeCapabilities
What the UI may offer for this thread.
Source§fn branches(&self, id: &MessageId) -> Result<Vec<MessageId>, RuntimeError>
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>
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>
fn switch_to_branch(&self, id: &MessageId) -> Result<(), RuntimeError>
Select the branch containing
id.Source§fn append(&self, message: AppendMessage) -> Result<RunFuture, RuntimeError>
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>
fn reload(&self, config: StartRunConfig) -> Result<RunFuture, RuntimeError>
Answer
parent_id again (regenerate).Source§fn cancel_run(&self)
fn cancel_run(&self)
Stop the run in progress, if any.
Source§fn add_tool_result(
&self,
result: ToolResult,
) -> Result<Option<RunFuture>, RuntimeError>
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>
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>
fn submit_feedback( &self, id: &MessageId, feedback: Option<SubmittedFeedback>, ) -> Result<(), RuntimeError>
None clears feedback.Source§fn begin_edit(&self, id: &MessageId) -> Result<Composer, RuntimeError>
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>
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
fn subscribe_dyn(&self, callback: Box<dyn Fn()>) -> Subscription
Called after every change; drop the guard to unsubscribe.
Source§fn export(&self) -> ExportedRepository
fn export(&self) -> ExportedRepository
Persisted messages and the selected head.
Source§fn import(&self, exported: ExportedRepository) -> Result<(), RuntimeError>
fn import(&self, exported: ExportedRepository) -> Result<(), RuntimeError>
Load history.
Source§fn structure_version(&self) -> Option<u64>
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>
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§
impl !RefUnwindSafe for ExternalStoreRuntime
impl !Send for ExternalStoreRuntime
impl !Sync for ExternalStoreRuntime
impl !UnwindSafe for ExternalStoreRuntime
impl Forget for ExternalStoreRuntime
impl Freeze for ExternalStoreRuntime
impl Move for ExternalStoreRuntime
impl Unpin for ExternalStoreRuntime
impl UnsafeUnpin for ExternalStoreRuntime
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