pub struct StreamConfig {
pub endpoint: String,
pub api_key: String,
pub staleness_threshold: Duration,
}Expand description
Configuration for a single stream connection.
Fields§
§endpoint: String§api_key: String§staleness_threshold: DurationImplementations§
Source§impl StreamConfig
impl StreamConfig
Sourcepub fn mainnet(api_key: impl Into<String>) -> Self
pub fn mainnet(api_key: impl Into<String>) -> Self
Default mainnet endpoint.
Examples found in repository?
examples/basic_stream.rs (line 20)
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}Sourcepub fn custom(endpoint: impl Into<String>, api_key: impl Into<String>) -> Self
pub fn custom(endpoint: impl Into<String>, api_key: impl Into<String>) -> Self
Custom endpoint (e.g., an enterprise / dedicated node URL).
Sourcepub fn staleness_threshold(self, d: Duration) -> Self
pub fn staleness_threshold(self, d: Duration) -> Self
How long without an update before the stream is considered stale. Default: 500ms.
Trait Implementations§
Source§impl Clone for StreamConfig
impl Clone for StreamConfig
Source§fn clone(&self) -> StreamConfig
fn clone(&self) -> StreamConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamConfig
impl RefUnwindSafe for StreamConfig
impl Send for StreamConfig
impl Sync for StreamConfig
impl Unpin for StreamConfig
impl UnsafeUnpin for StreamConfig
impl UnwindSafe for StreamConfig
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