pub trait DataSource: Send + Debug {
// Required methods
fn poll(&mut self) -> Option<Snapshot>;
fn description(&self) -> &str;
fn error(&self) -> Option<&str>;
}Expand description
Trait for receiving monitor data from various sources.
Implementations of this trait provide monitor snapshots from different backends - file polling, message bus subscriptions, or in-memory channels.
§Example
use buswatch_tui::{FileSource, DataSource};
let mut source = FileSource::new("monitor.json");
if let Some(snapshot) = source.poll() {
println!("Got {} modules", snapshot.len());
}Required Methods§
Sourcefn poll(&mut self) -> Option<Snapshot>
fn poll(&mut self) -> Option<Snapshot>
Poll for the latest snapshot.
Returns Some(snapshot) if new data is available, None otherwise.
This method should be non-blocking.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns a human-readable description of the source.
Used for display in the TUI status bar.