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
impl LogCorrelationState
Sourcepub fn new() -> Self
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());Sourcepub fn with_streams(self, streams: Vec<LogStream>) -> Self
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);Sourcepub fn with_title(self, title: impl Into<String>) -> Self
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"));Sourcepub fn with_sync_scroll(self, sync: bool) -> Self
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());Sourcepub fn streams(&self) -> &[LogStream]
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");Sourcepub fn stream_count(&self) -> usize
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);Sourcepub fn active_stream(&self) -> usize
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);Sourcepub fn sync_scroll(&self) -> bool
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 defaultSourcepub fn scroll_offset(&self) -> usize
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);Sourcepub fn scroll_timestamp(&self) -> f64
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);Sourcepub fn title(&self) -> Option<&str>
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);Sourcepub fn set_title(&mut self, title: impl Into<String>)
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"));Sourcepub fn add_stream(&mut self, stream: LogStream)
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);Sourcepub fn push_entry(&mut self, stream_idx: usize, entry: CorrelationEntry)
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);Sourcepub fn update(
&mut self,
msg: LogCorrelationMessage,
) -> Option<LogCorrelationOutput>
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
impl Clone for LogCorrelationState
Source§fn clone(&self) -> LogCorrelationState
fn clone(&self) -> LogCorrelationState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LogCorrelationState
impl Debug for LogCorrelationState
Source§impl Default for LogCorrelationState
impl Default for LogCorrelationState
Source§impl<'de> Deserialize<'de> for LogCorrelationState
impl<'de> Deserialize<'de> for LogCorrelationState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl PartialEq for LogCorrelationState
Auto Trait Implementations§
impl Freeze for LogCorrelationState
impl RefUnwindSafe for LogCorrelationState
impl Send for LogCorrelationState
impl Sync for LogCorrelationState
impl Unpin for LogCorrelationState
impl UnsafeUnpin for LogCorrelationState
impl UnwindSafe for LogCorrelationState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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