pub struct QuoteStream;Expand description
A stream that yields quote updates at regular intervals.
Implementations§
Source§impl QuoteStream
impl QuoteStream
Sourcepub fn create(
client: Arc<YahooFinanceClient>,
symbols: Vec<String>,
poll_interval: Duration,
) -> Pin<Box<dyn Stream<Item = Result<QuotesUpdate, YahooError>> + Send>>
pub fn create( client: Arc<YahooFinanceClient>, symbols: Vec<String>, poll_interval: Duration, ) -> Pin<Box<dyn Stream<Item = Result<QuotesUpdate, YahooError>> + Send>>
Create a new quote stream that fetches quotes for the given symbols at the specified interval.
§Arguments
client- The Yahoo Finance client to use for fetching quotessymbols- List of stock symbols to trackpoll_interval- How often to fetch new quotes
§Example
ⓘ
use finance_query_core::{QuoteStream, YahooFinanceClient};
use std::time::Duration;
use futures_util::StreamExt;
let stream = QuoteStream::create(&client, vec!["AAPL", "GOOGL"], Duration::from_secs(5));
while let Some(result) = stream.next().await {
match result {
Ok(update) => println!("Got {} quotes", update.len()),
Err(e) => eprintln!("Error: {}", e),
}
}Sourcepub fn with_default_interval(
client: Arc<YahooFinanceClient>,
symbols: Vec<String>,
) -> Pin<Box<dyn Stream<Item = Result<QuotesUpdate, YahooError>> + Send>>
pub fn with_default_interval( client: Arc<YahooFinanceClient>, symbols: Vec<String>, ) -> Pin<Box<dyn Stream<Item = Result<QuotesUpdate, YahooError>> + Send>>
Create a quote stream with a default 5-second interval.
Auto Trait Implementations§
impl Freeze for QuoteStream
impl RefUnwindSafe for QuoteStream
impl Send for QuoteStream
impl Sync for QuoteStream
impl Unpin for QuoteStream
impl UnsafeUnpin for QuoteStream
impl UnwindSafe for QuoteStream
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