Struct TerminalLine

Source
pub struct TerminalLine {
    pub text: String,
    pub kind: TerminalLineKind,
    pub attrs: TerminalLineAttrs,
    pub timestamp_ms: Option<i64>,
}
Expand description

One logical terminal line with semantic and optional timestamp metadata.

Text is stored unchanged and never parsed for ANSI escape sequences.

§Examples

use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
let line = TerminalLine::stderr("failed").timestamp_ms(1_000);
assert_eq!(line.kind, TerminalLineKind::Stderr);
assert_eq!(line.timestamp_ms, Some(1_000));

Fields§

§text: String

Unparsed line text without an implied newline.

§kind: TerminalLineKind

Semantic category selecting the base text style.

§attrs: TerminalLineAttrs

Optional color and emphasis overrides.

§timestamp_ms: Option<i64>

Optional caller-defined timestamp in milliseconds.

Implementations§

Source§

impl TerminalLine

Source

pub fn new(text: impl Into<String>) -> Self

Creates an untimestamped stdout line with default attributes.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
let line = TerminalLine::new("ready");
assert_eq!((line.text.as_str(), line.kind), ("ready", TerminalLineKind::Stdout));
Source

pub fn prompt(text: impl Into<String>) -> Self

Creates a prompt line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::prompt("$ ").kind, TerminalLineKind::Prompt);
Source

pub fn command(text: impl Into<String>) -> Self

Creates a command line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::command("cargo test").kind, TerminalLineKind::Command);
Source

pub fn stderr(text: impl Into<String>) -> Self

Creates a stderr line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::stderr("error").kind, TerminalLineKind::Stderr);
Source

pub fn system(text: impl Into<String>) -> Self

Creates a system-status line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::system("connected").kind, TerminalLineKind::System);
Source

pub fn success(text: impl Into<String>) -> Self

Creates a success line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::success("done").kind, TerminalLineKind::Success);
Source

pub fn warning(text: impl Into<String>) -> Self

Creates a warning line.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::warning("retrying").kind, TerminalLineKind::Warning);
Source

pub fn kind(self, kind: TerminalLineKind) -> Self

Replaces the semantic line category.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineKind};
assert_eq!(TerminalLine::new("ok").kind(TerminalLineKind::Success).kind, TerminalLineKind::Success);
Source

pub fn attrs(self, attrs: TerminalLineAttrs) -> Self

Replaces all per-line attributes.

§Examples
use ailloli_ui_widgets::controls::{TerminalLine, TerminalLineAttrs};
let line = TerminalLine::new("quiet").attrs(TerminalLineAttrs { dim: true, ..Default::default() });
assert!(line.attrs.dim);
Source

pub fn timestamp_ms(self, timestamp_ms: i64) -> Self

Sets caller-defined millisecond timestamp metadata.

Negative values are retained verbatim and no clock epoch is imposed.

§Examples
use ailloli_ui_widgets::controls::TerminalLine;
assert_eq!(TerminalLine::new("boot").timestamp_ms(-1).timestamp_ms, Some(-1));

Trait Implementations§

Source§

impl Clone for TerminalLine

Source§

fn clone(&self) -> TerminalLine

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 TerminalLine

Source§

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

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

impl PartialEq for TerminalLine

Source§

fn eq(&self, other: &TerminalLine) -> 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 StructuralPartialEq for TerminalLine

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.

§

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.

§

impl<A> IntoClickAction<A> for A
where A: Clone + 'static,

§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

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

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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Props for T
where T: Clone + 'static,