Struct TerminalSnapshot

Source
pub struct TerminalSnapshot {
Show 20 fields pub size: TerminalSize, pub active_screen: ActiveScreen, pub title: Option<String>, pub cwd_uri: Option<String>, pub cursor: TerminalSnapshotCursor, pub modes: TerminalModes, pub scrollback_len: usize, pub scrollback_limit: usize, pub scrollback_total_pushed: u64, pub damage_full: bool, pub dirty_lines: Vec<usize>, pub lines: Vec<TerminalSnapshotLine>, pub latest_output_lines: Vec<String>, pub shell: TerminalShellSnapshot, pub commands: Vec<CommandSummary>, pub diagnostics: Vec<TerminalDiagnostic>, pub warnings: Vec<TerminalWarning>, pub event_log: Vec<TerminalEventRecord>, pub hyperlinks: usize, pub truncated: bool,
}
Expand description

Owned, bounded observation of a TerminalState.

The selected line and command collections retain their newest entries, whereas diagnostics and warnings retain their oldest entries. Title, CWD, line text/cells, latest output, and shell command/CWD text are passed through the configured redaction policy. Diagnostics and warnings are copied verbatim, so their messages, paths, and other fields can still contain sensitive data. Dirty-line indices are also copied without a size limit.

Public fields and deserialization can construct internally inconsistent observations; this type deliberately performs no validation on deserialize.

§Examples

use ailloli_ui_terminal_core::{TerminalSnapshot, TerminalSnapshotConfig, TerminalState};

let mut state = TerminalState::new();
state.write_str("hello");
let snapshot = TerminalSnapshot::from_state(&state, TerminalSnapshotConfig::default());
assert_eq!(snapshot.active_screen, state.active_screen);
assert!(snapshot.lines.iter().any(|line| line.text.contains("hello")));

Fields§

§size: TerminalSize

Active screen size in rows and columns.

§active_screen: ActiveScreen

Screen whose lines were captured.

§title: Option<String>

Redacted terminal title, or None when the state has none.

§cwd_uri: Option<String>

Redacted current-working-directory URI, or None when unknown.

§cursor: TerminalSnapshotCursor

Cursor observation, including a normal-screen global line when available.

§modes: TerminalModes

Copy of current terminal modes.

§scrollback_len: usize

Total number of lines currently retained in normal-screen scrollback.

§scrollback_limit: usize

Configured scrollback retention limit; 0 retains no history.

§scrollback_total_pushed: u64

Saturating count of all lines ever pushed to scrollback.

§damage_full: bool

Whether the state’s damage tracker requests a full repaint.

§dirty_lines: Vec<usize>

Unbounded copy of the state’s dirty row indices.

§lines: Vec<TerminalSnapshotLine>

Newest captured visual lines in original visual order.

§latest_output_lines: Vec<String>

Newest captured full-line texts in original visual order.

This limit is independent of Self::lines and its cell limit.

§shell: TerminalShellSnapshot

Redacted shell/process/command snapshot.

§commands: Vec<CommandSummary>

Newest bounded command summaries, including the current command last.

§diagnostics: Vec<TerminalDiagnostic>

Oldest bounded diagnostics, copied without redaction.

§warnings: Vec<TerminalWarning>

Oldest bounded warnings, copied without redaction.

§event_log: Vec<TerminalEventRecord>

Newest bounded event records, or empty when no log was supplied.

§hyperlinks: usize

Number of registered hyperlinks; targets are not included.

§truncated: bool

Whether selected top-level state collections were omitted.

This is set for omitted visual lines, diagnostics, warnings, or command history according to the implementation’s history-versus-summary count. It does not report cell truncation, latest-output omission, event-log omission, byte/text truncation, redaction, or every possible command omission. Inspect nested flags and configured limits as well.

Implementations§

Source§

impl TerminalSnapshot

Source

pub fn from_state(state: &TerminalState, config: TerminalSnapshotConfig) -> Self

Captures state without attaching an event log.

This does not mutate state. Self::event_log is empty even if events were recorded elsewhere, because no log is accepted by this method.

§Examples
use ailloli_ui_terminal_core::{TerminalSnapshot, TerminalSnapshotConfig, TerminalState};

let snapshot = TerminalSnapshot::from_state(
    &TerminalState::new(),
    TerminalSnapshotConfig { max_lines: 1, ..Default::default() },
);
assert!(snapshot.lines.len() <= 1);
assert!(snapshot.event_log.is_empty());
Source

pub fn from_state_with_event_log( state: &TerminalState, config: TerminalSnapshotConfig, event_log: Option<&TerminalEventLog>, ) -> Self

Captures state and the newest configured records from an optional log.

None and an empty log both produce an empty event collection. Event records are copied as already sanitized at record time; changing the snapshot’s redaction policy does not re-sanitize existing records.

Line visual_index values refer to the full pre-limit visual sequence, not the returned vector. On the normal screen that sequence is scrollback followed by visible screen rows; on the alternate screen it contains only alternate-screen rows.

§Examples
use ailloli_ui_terminal_core::{
    TerminalEventLog, TerminalSnapshot, TerminalSnapshotConfig, TerminalState,
};

let config = TerminalSnapshotConfig::unredacted_for_tests();
let mut log = TerminalEventLog::new(2);
assert_eq!(log.record_output(b"ok", &config), 1);
let snapshot = TerminalSnapshot::from_state_with_event_log(
    &TerminalState::new(), config, Some(&log),
);
assert_eq!(snapshot.event_log.len(), 1);

Trait Implementations§

Source§

impl Clone for TerminalSnapshot

Source§

fn clone(&self) -> TerminalSnapshot

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TerminalSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TerminalSnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TerminalSnapshot

Source§

fn eq(&self, other: &TerminalSnapshot) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TerminalSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for TerminalSnapshot

Source§

impl StructuralPartialEq for TerminalSnapshot

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 = 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,