Struct HolidayAPI

Source
pub struct HolidayAPI { /* private fields */ }

Implementations§

Source§

impl HolidayAPI

Source

pub fn is_valid_key(key: &str) -> Result<(), HolidayAPIError>

Source

pub fn is_valid_version(version: &i32) -> Result<(), HolidayAPIError>

Source

pub fn new(key: &str) -> Result<HolidayAPI, HolidayAPIError>

Construct a new holiday API

§Errors

Will return an Err if the given key is not plausibly a valid one.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
Source

pub fn with_version( key: &str, version: i32, ) -> Result<HolidayAPI, HolidayAPIError>

Construct a new holiday API

§Errors

Will return an Err if the given key is not plausibly a valid one. Or the api version is invalid. Current valid versions: [1]

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::with_version("00000000-0000-0000-0000-000000000000", 1).unwrap();
Source

pub async fn custom_request( &self, endpoint: &str, parameters: HashMap<String, String>, ) -> Result<Response, Box<dyn Error>>

Make a custom request.

§Examples

Basic usage

use holidayapi_rust::{ HolidayAPI };
use std::collections::HashMap;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let _future = api.custom_request("countries", HashMap::new());
Source

pub fn countries(&self) -> Request<CountriesResponse>

Generates a minimal countries request and returns it.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let request = api.countries();

Adding optional parameters with builder pattern

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let specific_request = api.countries().search("united states").public();
Source

pub fn holidays(&self, country: &str, year: i32) -> Request<HolidaysResponse>

Generates a minimal holidays request and returns it.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let request = api.holidays("us", 2020);

Adding optional parameters with builder pattern

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let specific_request = api.holidays("us", 2020).month(12).upcoming();
Source

pub fn workday( &self, country: &str, start: &str, days: i32, ) -> Request<WorkdayResponse>

Generates a minimal workday request and returns it.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let request = api.workday("us","YYYY-MM-DD", 100);
Source

pub fn workdays( &self, country: &str, start: &str, days: &str, ) -> Request<WorkdaysResponse>

Generates a minimal workdays request and returns it.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let request = api.workdays("us", "YYYY-MM-DD", "YYYY-MM-DD");
Source

pub fn languages(&self) -> Request<LanguagesResponse>

Generates a minimal languages request and returns it.

§Examples

Basic usage

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let request = api.languages();

Adding optional parameters with builder pattern

use holidayapi_rust::prelude::*;

let api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
let specific_request = api.languages().search("united states");

Trait Implementations§

Source§

impl Clone for HolidayAPI

Source§

fn clone(&self) -> HolidayAPI

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HolidayAPI

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,