pub struct RichLogState {
pub auto_scroll: bool,
pub max_entries: Option<usize>,
/* private fields */
}Expand description
State for the rich log viewer widget.
Fields§
§auto_scroll: boolWhether to auto-scroll to bottom when new entries are added.
max_entries: Option<usize>Maximum number of entries to keep (None = unlimited).
Implementations§
Source§impl RichLogState
impl RichLogState
Sourcepub const DEFAULT_MAX_ENTRIES: usize = 10_000
pub const DEFAULT_MAX_ENTRIES: usize = 10_000
Default maximum entry cap used by RichLogState::new.
Long-running apps that push log entries continuously would otherwise
accumulate state without bound. Use RichLogState::new_unbounded to
opt out explicitly.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty rich log state with the default entry cap
(Self::DEFAULT_MAX_ENTRIES).
Sourcepub fn new_unbounded() -> Self
pub fn new_unbounded() -> Self
Create an empty rich log state without an entry cap.
Prefer RichLogState::new in long-running apps. Use this constructor
only when the host explicitly bounds growth elsewhere.
Sourcepub fn push(&mut self, text: impl Into<String>, style: Style)
pub fn push(&mut self, text: impl Into<String>, style: Style)
Add a single-style entry to the log.
Sourcepub fn push_plain(&mut self, text: impl Into<String>)
pub fn push_plain(&mut self, text: impl Into<String>)
Add a plain text entry using default style.
Sourcepub fn push_segments(&mut self, segments: Vec<(String, Style)>)
pub fn push_segments(&mut self, segments: Vec<(String, Style)>)
Add a multi-segment styled entry to the log.
Sourcepub fn push_entry(&mut self, entry: RichLogEntry)
pub fn push_entry(&mut self, entry: RichLogEntry)
Add a pre-built entry to the log and enforce the configured cap.
This replaces direct entries.push(...) access from earlier releases.
Sourcepub fn entries(
&self,
) -> impl DoubleEndedIterator<Item = &RichLogEntry> + ExactSizeIterator + '_
pub fn entries( &self, ) -> impl DoubleEndedIterator<Item = &RichLogEntry> + ExactSizeIterator + '_
Iterate over entries from oldest to newest.
This replaces entries.iter() from earlier releases. Use entry
for indexed access.
Sourcepub fn entries_mut(
&mut self,
) -> impl DoubleEndedIterator<Item = &mut RichLogEntry> + ExactSizeIterator + '_
pub fn entries_mut( &mut self, ) -> impl DoubleEndedIterator<Item = &mut RichLogEntry> + ExactSizeIterator + '_
Mutably iterate over entries from oldest to newest.
Entry contents may be changed, but insertion and removal remain behind
push_entry and clear so retention
invariants cannot be bypassed.
Sourcepub fn entry(&self, index: usize) -> Option<&RichLogEntry>
pub fn entry(&self, index: usize) -> Option<&RichLogEntry>
Return an entry by its zero-based position in oldest-to-newest order.
This replaces entries[index] from earlier releases without exposing
the retention storage type.
Sourcepub fn entry_mut(&mut self, index: usize) -> Option<&mut RichLogEntry>
pub fn entry_mut(&mut self, index: usize) -> Option<&mut RichLogEntry>
Return a mutable entry by its zero-based position in retention order.
Trait Implementations§
Source§impl Clone for RichLogState
impl Clone for RichLogState
Source§fn clone(&self) -> RichLogState
fn clone(&self) -> RichLogState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more