Skip to main content

LogCorrelationState

Struct LogCorrelationState 

Source
pub struct LogCorrelationState { /* private fields */ }
Expand description

State for a LogCorrelation component.

Contains the log streams, scroll position, active stream index, and configuration for synchronized scrolling.

Implementations§

Source§

impl LogCorrelationState

Source

pub fn new() -> Self

Creates a new empty log correlation state.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new();
assert_eq!(state.stream_count(), 0);
assert!(state.sync_scroll());
Source

pub fn with_streams(self, streams: Vec<LogStream>) -> Self

Sets the initial streams (builder pattern).

§Example
use envision::component::{LogCorrelationState, LogStream};

let state = LogCorrelationState::new()
    .with_streams(vec![
        LogStream::new("API"),
        LogStream::new("DB"),
    ]);
assert_eq!(state.stream_count(), 2);
Source

pub fn with_title(self, title: impl Into<String>) -> Self

Sets the title (builder pattern).

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new()
    .with_title("Log Correlation");
assert_eq!(state.title(), Some("Log Correlation"));
Source

pub fn with_sync_scroll(self, sync: bool) -> Self

Sets whether scrolling is synchronized (builder pattern).

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new()
    .with_sync_scroll(false);
assert!(!state.sync_scroll());
Source

pub fn streams(&self) -> &[LogStream]

Returns all streams.

§Example
use envision::component::{LogCorrelationState, LogStream};

let state = LogCorrelationState::new()
    .with_streams(vec![LogStream::new("API"), LogStream::new("DB")]);
assert_eq!(state.streams().len(), 2);
assert_eq!(state.streams()[0].name, "API");
Source

pub fn stream_count(&self) -> usize

Returns the number of streams.

§Example
use envision::component::{LogCorrelationState, LogStream};

let state = LogCorrelationState::new()
    .with_streams(vec![LogStream::new("A"), LogStream::new("B")]);
assert_eq!(state.stream_count(), 2);
Source

pub fn active_stream(&self) -> usize

Returns the index of the active (focused) stream.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new();
assert_eq!(state.active_stream(), 0);
Source

pub fn sync_scroll(&self) -> bool

Returns whether synchronized scrolling is enabled.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new();
assert!(state.sync_scroll()); // enabled by default
Source

pub fn scroll_offset(&self) -> usize

Returns the scroll offset.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new();
assert_eq!(state.scroll_offset(), 0);
Source

pub fn scroll_timestamp(&self) -> f64

Returns the current scroll timestamp.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new();
assert_eq!(state.scroll_timestamp(), 0.0);
Source

pub fn title(&self) -> Option<&str>

Returns the title.

§Example
use envision::component::LogCorrelationState;

let state = LogCorrelationState::new().with_title("Logs");
assert_eq!(state.title(), Some("Logs"));

let no_title = LogCorrelationState::new();
assert_eq!(no_title.title(), None);
Source

pub fn set_title(&mut self, title: impl Into<String>)

Sets the title.

§Example
use envision::component::LogCorrelationState;

let mut state = LogCorrelationState::new();
state.set_title("Correlated Logs");
assert_eq!(state.title(), Some("Correlated Logs"));
Source

pub fn add_stream(&mut self, stream: LogStream)

Adds a new log stream.

§Example
use envision::component::{LogCorrelationState, LogStream};

let mut state = LogCorrelationState::new();
state.add_stream(LogStream::new("API"));
assert_eq!(state.stream_count(), 1);
Source

pub fn push_entry(&mut self, stream_idx: usize, entry: CorrelationEntry)

Pushes an entry to the specified stream.

§Example
use envision::component::{
    LogCorrelationState, LogStream,
    CorrelationEntry, CorrelationLevel,
};

let mut state = LogCorrelationState::new()
    .with_streams(vec![LogStream::new("API")]);
state.push_entry(0, CorrelationEntry::new(1.0, CorrelationLevel::Info, "Hello"));
assert_eq!(state.streams()[0].entries.len(), 1);
Source

pub fn update( &mut self, msg: LogCorrelationMessage, ) -> Option<LogCorrelationOutput>

Updates the state with a message, returning any output.

§Example
use envision::component::{
    LogCorrelationState, LogCorrelationMessage, LogCorrelationOutput, LogStream,
};

let mut state = LogCorrelationState::new()
    .with_streams(vec![LogStream::new("A"), LogStream::new("B")]);
let output = state.update(LogCorrelationMessage::FocusNextStream);
assert_eq!(output, Some(LogCorrelationOutput::StreamFocused(1)));

Trait Implementations§

Source§

impl Clone for LogCorrelationState

Source§

fn clone(&self) -> LogCorrelationState

Returns a duplicate 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 LogCorrelationState

Source§

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

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

impl Default for LogCorrelationState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for LogCorrelationState

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 LogCorrelationState

Source§

fn eq(&self, other: &Self) -> 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 LogCorrelationState

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> StateExt for T

Source§

fn updated(self, cmd: Command<impl Clone>) -> UpdateResult<Self, impl Clone>

Updates self and returns a command.
Source§

fn unchanged(self) -> UpdateResult<Self, ()>

Returns self with no command.
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>,