Skip to main content

Application

Struct Application 

Source
pub struct Application { /* private fields */ }

Implementations§

Source§

impl Application

Source

pub fn request_harness_models( &self, harness: HarnessId, folder: Option<PathBuf>, ) -> ModelListRequest

Starts listing the models harness offers, read from its own CLI on another thread, so a slow harness never holds up commands or terminals. Poll the request for the result.

Source§

impl Application

Source

pub fn save_file( &self, request: &FileSaveRequest, ) -> Result<FileSaveOutcome, ApplicationError>

Saves a bounded text edit, returning a conflict without writing when the disk version differs. Contents never enter the event journal. Call on a worker, as this performs disk I/O.

§Errors

Returns an error for a stale folder, invalid/unsupported paths, oversized text, or failed I/O.

Source

pub fn poll_files( &self, folder: &Path, directories: &[PathBuf], file: Option<&Path>, revision: Option<u64>, ) -> Result<Option<FileSnapshot>, ApplicationError>

Watches only the visible directories and selected file on a dedicated worker. Returns no snapshot until the first scan completes or while the revision is unchanged. File contents stay out of the event journal, which would retain old versions. Poll at 500 ms intervals.

§Errors

Returns an error for a stale folder, invalid paths, or poisoned state locks.

Source§

impl Application

Source

pub fn workflow_types(&self) -> Result<Vec<WorkflowType>, ApplicationError>

Lists built-in and stored custom types for launch forms.

§Errors

Returns an error when the catalog cannot be read.

Source§

impl Application

Source

pub fn next_terminal_chunk( &self, ) -> Result<Option<TerminalChunk>, ApplicationError>

Removes the next terminal chunk from the binary output queue.

§Errors

Returns an error if the queue cannot be accessed.

Source

pub fn read_terminal_transcript( &self, terminal_id: TerminalId, offset: u64, limit: usize, ) -> Result<TranscriptRead, ApplicationError>

Reads at most limit raw bytes beginning exactly at offset, after committing output already accepted for recording. limit must be between 1 and 64 KiB. An offset at the recorded end returns an empty page; pruned history returns an explicit expired result.

This performs storage work on the recording worker and waits for its reply. Call it off the UI thread. It acquires no application-state or terminal-input locks.

§Errors

Returns an error for an invalid limit, an unknown terminal, an offset beyond the recorded end, or unavailable/corrupt storage. Terminal IDs remain readable after terminal closure.

Source

pub fn request_terminal_transcript( &self, terminal_id: TerminalId, offset: u64, limit: usize, ) -> Result<Option<TranscriptRequest>, ApplicationError>

Begins a transcript read without waiting for recording or storage. None means the bounded request queue is full; callers may retry while continuing to service live terminals.

§Errors

Returns an invalid limit, cancellation, or a recording failure.

Source

pub fn write_terminal_input( &self, terminal_id: TerminalId, bytes: &[u8], ) -> Result<(), ApplicationError>

Writes binary user input to a live terminal.

§Errors

Returns an error if the terminal is not running or the PTY writer fails.

Source

pub fn write_terminal_response( &self, terminal_id: TerminalId, bytes: &[u8], ) -> Result<(), ApplicationError>

Writes a terminal-generated protocol reply without treating it as a user draft.

§Errors

Returns an error if the terminal is not running or the PTY writer fails.

Source

pub fn resize_terminal( &self, terminal_id: TerminalId, size: TerminalSize, ) -> Result<(), ApplicationError>

Changes the kernel PTY size for a live terminal.

§Errors

Returns an error if the size is invalid, the terminal is not running, or resizing fails.

Source§

impl Application

Source

pub fn trace_storage_status( &self, span: Option<TraceSpanId>, ) -> Result<TraceStorageStatus, ApplicationError>

Reads cached trace storage statistics and schedules background maintenance.

§Errors

Returns storage or application-lock failures.

Source

pub fn pin_trace_details( &self, span: TraceSpanId, pinned: bool, ) -> Result<(), ApplicationError>

Protects a step’s full retained details from automatic cleanup.

§Errors

Returns storage or application-lock failures.

Source

pub fn clear_trace_details(&self) -> Result<(), ApplicationError>

Clears unpinned, completed full details in the background. Native files are untouched.

§Errors

Returns storage or application-lock failures.

Source

pub fn trace_detail( &self, activity: TraceActivityId, output: bool, offset: u64, limit: usize, ) -> Result<TraceDetailPage, ApplicationError>

Reads full recorded activity input or output in bounded UTF-8 pages.

§Errors

Returns an error for missing activity, invalid page size, or unavailable payload storage.

Source

pub fn trace_activities( &self, span_id: TraceSpanId, after: Option<TraceActivityId>, limit: usize, ) -> Result<TraceActivitiesPage, ApplicationError>

Reads native tool and subagent activity in stable ID order. Refresh from the beginning when the workflow revision changes, because a finish updates an existing activity.

§Errors

Returns an error if the span is missing, the page limit is invalid, or storage fails.

Source

pub fn workflow_trace( &self, workflow_id: WorkflowId, before: Option<TraceSpanId>, limit: usize, ) -> Result<WorkflowTracePage, ApplicationError>

Reads a bounded page of the workflow’s durable trace, including closed workflow history.

§Errors

Returns an error if the workflow is missing, the page limit is invalid, or storage fails.

Source

pub fn trace_events( &self, span_id: TraceSpanId, after: Option<TraceEventId>, limit: usize, ) -> Result<TraceEventsPage, ApplicationError>

Reads a bounded page of events for a span, in durable event ID order.

§Errors

Returns an error if the span is missing, the page limit is invalid, or storage fails.

Source§

impl Application

Source

pub fn new_window(data_directory: &Path) -> Result<Self, ApplicationError>

Creates an independent window runtime sharing durable history with the other windows. Only the first runtime recovers interrupted work and restores a previously open folder.

§Errors

Returns an error if storage, recovery, or runtime initialization fails.

Source

pub fn restorable_folders(&self) -> Result<Vec<PathBuf>, ApplicationError>

Returns every folder that should reopen after app shutdown, including unavailable folders.

§Errors

Returns an error if the database or runtime state cannot be read.

Source§

impl Application

Source

pub fn new(data_directory: &Path) -> Result<Self, ApplicationError>

Creates the application with production queue limits and the user’s config file, keeping its database in data_directory, and reopens the folder that was open when Twine last quit.

§Errors

Returns an error if the database cannot be opened or migrated, transcript storage cannot be opened or is owned by another core, or the initial ready event cannot be recorded.

Source

pub fn with_config( data_directory: &Path, config: Config, ) -> Result<Self, ApplicationError>

Creates the application like Application::new, but with already validated configuration instead of the user’s config file.

§Errors

Returns an error if the database cannot be opened or migrated, transcript storage cannot be opened or is owned by another core, or the initial ready event cannot be recorded.

Source

pub fn handle_command( &self, request_id: RequestId, command: Command, ) -> Result<CommandReceipt, ApplicationError>

Handles a command and returns its immediate acceptance result.

§Errors

Returns an error if application state cannot be accessed or the resulting event cannot be recorded.

Source

pub fn snapshot(&self) -> Result<Snapshot, ApplicationError>

Returns an atomic snapshot of application state and the latest event sequence.

§Errors

Returns an error if application state cannot be accessed.

Source

pub fn events_after( &self, sequence: u64, limit: usize, ) -> Result<Vec<Event>, ApplicationError>

Returns at most limit events whose sequence is strictly greater than sequence.

§Errors

Returns an error if the cursor has expired, the limit is invalid, or application state cannot be accessed.

Trait Implementations§

Source§

impl Drop for Application

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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