pub struct RestStream { /* private fields */ }Expand description
A configured REST API stream that handles pagination, auth, and extraction.
Implementations§
Source§impl RestStream
impl RestStream
Sourcepub fn new(config: RestStreamConfig) -> Result<Self, FaucetError>
pub fn new(config: RestStreamConfig) -> Result<Self, FaucetError>
Create a new stream from the given configuration.
Sourcepub async fn fetch_all(&self) -> Result<Vec<Value>, FaucetError>
pub async fn fetch_all(&self) -> Result<Vec<Value>, FaucetError>
Fetch all records across all pages as raw JSON values.
Sourcepub async fn fetch_all_as<T: for<'de> Deserialize<'de>>(
&self,
) -> Result<Vec<T>, FaucetError>
pub async fn fetch_all_as<T: for<'de> Deserialize<'de>>( &self, ) -> Result<Vec<T>, FaucetError>
Fetch all records and deserialize into typed structs.
Sourcepub fn stream_pages(
&self,
) -> Pin<Box<dyn Stream<Item = Result<Vec<Value>, FaucetError>> + '_>>
pub fn stream_pages( &self, ) -> Pin<Box<dyn Stream<Item = Result<Vec<Value>, FaucetError>> + '_>>
Stream records page-by-page, yielding one Vec<Value> per page as it arrives.
Unlike fetch_all, this does not wait for all pages to be fetched
before returning — callers can process each page immediately.
use faucet_stream::{RestStream, RestStreamConfig};
use futures::StreamExt;
let stream = RestStream::new(RestStreamConfig::new("https://api.example.com", "/items"))?;
let mut pages = stream.stream_pages();
while let Some(page) = pages.next().await {
let records = page?;
println!("got {} records", records.len());
}Auto Trait Implementations§
impl Freeze for RestStream
impl !RefUnwindSafe for RestStream
impl Send for RestStream
impl Sync for RestStream
impl Unpin for RestStream
impl UnsafeUnpin for RestStream
impl !UnwindSafe for RestStream
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