pub struct RealtimeClient<'a> { /* private fields */ }Expand description
Realtime API client for SSE streaming.
Implementations§
Source§impl<'a> RealtimeClient<'a>
impl<'a> RealtimeClient<'a>
Sourcepub async fn connect(
&self,
options: &RealtimeConnectOptions,
filters: Option<&RequestParams>,
) -> Result<Box<dyn Stream<Item = Result<ArticleUpdate>> + Send + Unpin>>
pub async fn connect( &self, options: &RealtimeConnectOptions, filters: Option<&RequestParams>, ) -> Result<Box<dyn Stream<Item = Result<ArticleUpdate>> + Send + Unpin>>
Connect to the realtime SSE stream.
§Arguments
options- Connection options including resume timestampsfilters- Optional filters for the stream
§Returns
A stream of article updates. The stream yields ArticleUpdate items
parsed from the SSE events.
§Example
use wme_client::{WmeClient, RealtimeConnectOptions};
use futures::StreamExt;
use chrono::Utc;
let options = RealtimeConnectOptions::since(Utc::now());
let mut stream = client.realtime().connect(&options, None).await?;
while let Some(result) = stream.next().await {
match result {
Ok(update) => println!("Article: {}", update.article.name),
Err(e) => eprintln!("Error: {}", e),
}
}Sourcepub async fn list_batches(
&self,
date: &str,
hour: &str,
) -> Result<Vec<RealtimeBatchInfo>>
pub async fn list_batches( &self, date: &str, hour: &str, ) -> Result<Vec<RealtimeBatchInfo>>
List available hourly batches for a specific date and hour.
Sourcepub async fn list_batches_with_params(
&self,
date: &str,
hour: &str,
params: Option<&RequestParams>,
) -> Result<Vec<RealtimeBatchInfo>>
pub async fn list_batches_with_params( &self, date: &str, hour: &str, params: Option<&RequestParams>, ) -> Result<Vec<RealtimeBatchInfo>>
List batches with filters and field selection.
Sourcepub async fn get_batch_info(
&self,
date: &str,
hour: &str,
identifier: &str,
) -> Result<RealtimeBatchInfo>
pub async fn get_batch_info( &self, date: &str, hour: &str, identifier: &str, ) -> Result<RealtimeBatchInfo>
Get specific batch metadata.
Sourcepub async fn get_batch_info_with_params(
&self,
date: &str,
hour: &str,
identifier: &str,
params: Option<&RequestParams>,
) -> Result<RealtimeBatchInfo>
pub async fn get_batch_info_with_params( &self, date: &str, hour: &str, identifier: &str, params: Option<&RequestParams>, ) -> Result<RealtimeBatchInfo>
Get batch metadata with field selection.
Sourcepub async fn download_batch(
&self,
date: &str,
hour: &str,
identifier: &str,
range: Option<&str>,
) -> Result<Box<dyn Stream<Item = Result<Bytes>> + Send + Unpin>>
pub async fn download_batch( &self, date: &str, hour: &str, identifier: &str, range: Option<&str>, ) -> Result<Box<dyn Stream<Item = Result<Bytes>> + Send + Unpin>>
Download a batch as a stream of bytes.
Sourcepub async fn stream_batch(
&self,
date: &str,
hour: &str,
identifier: &str,
) -> Result<Box<dyn Stream<Item = Result<Article>> + Send + Unpin>>
pub async fn stream_batch( &self, date: &str, hour: &str, identifier: &str, ) -> Result<Box<dyn Stream<Item = Result<Article>> + Send + Unpin>>
Download a batch and parse it as a stream of articles.
This method downloads the batch tarball, decompresses it, and parses the NDJSON content into Article structs.
§Example
use wme_client::{WmeClient, RealtimeConnectOptions};
use futures::StreamExt;
let mut stream = client.realtime().stream_batch("2024-01-15", "12", "batch_id").await?;
while let Some(result) = stream.next().await {
match result {
Ok(article) => println!("Article: {}", article.name),
Err(e) => eprintln!("Error: {}", e),
}
}Auto Trait Implementations§
impl<'a> Freeze for RealtimeClient<'a>
impl<'a> !RefUnwindSafe for RealtimeClient<'a>
impl<'a> Send for RealtimeClient<'a>
impl<'a> Sync for RealtimeClient<'a>
impl<'a> Unpin for RealtimeClient<'a>
impl<'a> UnsafeUnpin for RealtimeClient<'a>
impl<'a> !UnwindSafe for RealtimeClient<'a>
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