pub struct LayerQuery { /* private fields */ }Expand description
Query builder for the getDataLayer endpoint.
Constraints enforced at build time:
DBmust be non-empty ASCII and must not contain commas.LAYERmust contain between1and5entries.- Each layer entry must be either
*or a positive integer. - Date format depends on
frequency:CY/FY:YYYYCH/FH:YYYYXXwhereXXis01..02Q:YYYYXXwhereXXis01..04M/W/D:YYYYXXwhereXXis01..12
- If both dates are set they must share the same format and satisfy
startDate <= endDate.
§Examples
use boj_client::query::{Format, Frequency, Language, LayerQuery};
let _query = LayerQuery::new("BP01", Frequency::Q, vec!["1".to_string(), "*".to_string()])?
.with_format(Format::Json)
.with_lang(Language::En)
.with_start_date("202401")?
.with_end_date("202404")?;Implementations§
Source§impl LayerQuery
impl LayerQuery
Sourcepub fn new(
db: impl Into<String>,
frequency: Frequency,
layers: Vec<String>,
) -> Result<Self, BojError>
pub fn new( db: impl Into<String>, frequency: Frequency, layers: Vec<String>, ) -> Result<Self, BojError>
Sourcepub fn with_format(self, format: Format) -> Self
pub fn with_format(self, format: Format) -> Self
Sets the response format (json or csv).
§Examples
use boj_client::query::{Format, Frequency, LayerQuery};
let _query = LayerQuery::new("BP01", Frequency::M, vec!["1".to_string()])?
.with_format(Format::Csv);Sourcepub fn with_lang(self, lang: Language) -> Self
pub fn with_lang(self, lang: Language) -> Self
Sets response language (jp or en).
§Examples
use boj_client::query::{Frequency, Language, LayerQuery};
let _query = LayerQuery::new("BP01", Frequency::M, vec!["1".to_string()])?
.with_lang(Language::Jp);Sourcepub fn with_start_date(self, value: impl Into<String>) -> Result<Self, BojError>
pub fn with_start_date(self, value: impl Into<String>) -> Result<Self, BojError>
Sets startDate using the date format implied by frequency.
§Examples
use boj_client::query::{Frequency, LayerQuery};
let _query = LayerQuery::new("BP01", Frequency::Q, vec!["1".to_string()])?
.with_start_date("202401")?;§Errors
Returns BojError if the date format is invalid for the selected
frequency, or if endDate is already set and the date order is
invalid.
Sourcepub fn with_end_date(self, value: impl Into<String>) -> Result<Self, BojError>
pub fn with_end_date(self, value: impl Into<String>) -> Result<Self, BojError>
Sets endDate using the date format implied by frequency.
§Examples
use boj_client::query::{Frequency, LayerQuery};
let _query = LayerQuery::new("BP01", Frequency::Q, vec!["1".to_string()])?
.with_end_date("202404")?;§Errors
Returns BojError if the date format is invalid for the selected
frequency, or if startDate is already set and the date order is
invalid.
Sourcepub fn with_start_position(self, start_position: u32) -> Result<Self, BojError>
pub fn with_start_position(self, start_position: u32) -> Result<Self, BojError>
Trait Implementations§
Source§impl Clone for LayerQuery
impl Clone for LayerQuery
Source§fn clone(&self) -> LayerQuery
fn clone(&self) -> LayerQuery
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LayerQuery
impl Debug for LayerQuery
Source§impl PartialEq for LayerQuery
impl PartialEq for LayerQuery
impl Eq for LayerQuery
impl StructuralPartialEq for LayerQuery
Auto Trait Implementations§
impl Freeze for LayerQuery
impl RefUnwindSafe for LayerQuery
impl Send for LayerQuery
impl Sync for LayerQuery
impl Unpin for LayerQuery
impl UnsafeUnpin for LayerQuery
impl UnwindSafe for LayerQuery
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