pub struct ObservationsRequest<'a> { /* private fields */ }Expand description
A builder for an observations request, returned by Client::observations.
Only parameters you set are sent; anything left unset uses FRED’s default
(full history, Levels units, ascending by date, the series’ native
frequency). Finish with send.
use ferric_fred::{SeriesId, SortOrder, Units};
let latest = client
.observations(&SeriesId::new("UNRATE"))
.units(Units::PercentChange)
.sort_order(SortOrder::Descending)
.limit(12)
.send()
.await?;Implementations§
Source§impl<'a> ObservationsRequest<'a>
impl<'a> ObservationsRequest<'a>
Sourcepub fn observation_start(self, date: NaiveDate) -> Self
pub fn observation_start(self, date: NaiveDate) -> Self
Earliest observation date to return (observation_start).
Sourcepub fn observation_end(self, date: NaiveDate) -> Self
pub fn observation_end(self, date: NaiveDate) -> Self
Latest observation date to return (observation_end).
Sourcepub fn date_range(self, start: NaiveDate, end: NaiveDate) -> Self
pub fn date_range(self, start: NaiveDate, end: NaiveDate) -> Self
Convenience for setting both ends of the date range at once.
Sourcepub fn frequency(self, frequency: Frequency) -> Self
pub fn frequency(self, frequency: Frequency) -> Self
Aggregate observations down to a lower frequency. Pair with
aggregation_method to control how.
Sourcepub fn aggregation_method(self, method: AggregationMethod) -> Self
pub fn aggregation_method(self, method: AggregationMethod) -> Self
How to aggregate when a lower frequency is set
(aggregation_method).
Sourcepub fn sort_order(self, order: SortOrder) -> Self
pub fn sort_order(self, order: SortOrder) -> Self
Sort order of the returned observations by date (sort_order).
Sourcepub fn limit(self, limit: u32) -> Self
pub fn limit(self, limit: u32) -> Self
Maximum number of observations to return, 1..=100000 (limit).
Sourcepub fn offset(self, offset: u32) -> Self
pub fn offset(self, offset: u32) -> Self
Number of observations to skip from the start (offset), for paging.
Sourcepub fn realtime(self, start: NaiveDate, end: NaiveDate) -> Self
pub fn realtime(self, start: NaiveDate, end: NaiveDate) -> Self
Return the data as it was known over this real-time period
(realtime_start/realtime_end) — the ALFRED / point-in-time dimension
(ADR-0024). Pass the same date twice for a point-in-time snapshot (the
series as it looked on that day); pass a window to see each value’s
real-time period. Each returned Observation carries its own
realtime_start/realtime_end.
Sourcepub fn vintage_dates(self, dates: impl IntoIterator<Item = NaiveDate>) -> Self
pub fn vintage_dates(self, dates: impl IntoIterator<Item = NaiveDate>) -> Self
Return the data as of these specific revision dates (vintage_dates) —
each date selects that vintage of the series (ALFRED, ADR-0024).
Complements realtime; an empty list is ignored.
Trait Implementations§
Source§impl<'a> Clone for ObservationsRequest<'a>
impl<'a> Clone for ObservationsRequest<'a>
Source§fn clone(&self) -> ObservationsRequest<'a>
fn clone(&self) -> ObservationsRequest<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more