pub struct StreamHealth { /* private fields */ }Expand description
Tracks slot continuity, gaps, and freshness of incoming updates.
Implementations§
Source§impl StreamHealth
impl StreamHealth
pub fn new() -> Self
Sourcepub fn record_update(&mut self, slot: u64) -> bool
pub fn record_update(&mut self, slot: u64) -> bool
Returns true if this update revealed a slot gap.
pub fn is_stale(&self, max_age: Duration) -> bool
pub fn last_slot(&self) -> u64
pub fn total_gaps(&self) -> u64
pub fn total_updates(&self) -> u64
pub fn max_observed_gap(&self) -> u64
pub fn consecutive_clean(&self) -> u64
Sourcepub fn gap_rate(&self) -> f64
pub fn gap_rate(&self) -> f64
Examples found in repository?
examples/basic_stream.rs (line 35)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 // No logger init — keeps example dependency-free.
14 // The crate uses `log` facade; to see internal logs, add env_logger
15 // (or any log backend) to your binary's Cargo.toml and init here.
16
17 let api_key = std::env::var("HELIUS_API_KEY")
18 .map_err(|_| "set HELIUS_API_KEY in environment")?;
19
20 let config = StreamConfig::mainnet(api_key);
21 let mut stream = HeliusStream::connect(config)?;
22
23 println!("[INIT] subscribing to USDC mint");
24 stream.subscribe_account_b58(USDC_MINT)?;
25
26 let mut received = 0;
27 while let Some(update) = stream.next_update() {
28 received += 1;
29 println!(
30 "[UPDATE] slot={} lamports={} data_bytes={} safe={} gap_rate={:.3}",
31 update.slot,
32 update.lamports,
33 update.data.len(),
34 stream.is_safe_for_simulation(),
35 stream.health().gap_rate(),
36 );
37 if received >= 10 {
38 println!("[DONE] received 10 updates, exiting");
39 break;
40 }
41 }
42 Ok(())
43}pub fn last_update(&self) -> Instant
Trait Implementations§
Source§impl Debug for StreamHealth
impl Debug for StreamHealth
Auto Trait Implementations§
impl Freeze for StreamHealth
impl RefUnwindSafe for StreamHealth
impl Send for StreamHealth
impl Sync for StreamHealth
impl Unpin for StreamHealth
impl UnsafeUnpin for StreamHealth
impl UnwindSafe for StreamHealth
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