[][src]Struct accuweather::Accuweather

pub struct Accuweather {
    pub client: Client,
    pub api_key: String,
    pub location: Option<i32>,
    pub language: String,
    // some fields omitted
}

Fields

client: Clientapi_key: Stringlocation: Option<i32>language: String

Methods

impl Accuweather[src]

pub fn new(
    api_key: String,
    location: Option<i32>,
    language: Option<String>
) -> Self
[src]

Create an Accuweather client

It takes as parameters:

  • api_key: a String with you api key for Accuweather
  • location: An optional id specifying the location to get weather from #Example
fn main() {
   let api_key = "abcdefg".to_string();
   let client = accuweather::Accuweather::new(api_key, None, None);
}

pub fn set_location(&mut self, location: Option<i32>)[src]

Set location for an Accuweather client

Take an Option to specify location id

Example

 let api_key = "abcdefg".to_string();
 let mut client = accuweather::Accuweather::new(api_key, None, None);
 client.set_location(Some(1234));
 assert_eq!(client.location, Some(1234));

pub fn debug(&self)[src]

Debug with println! a client

pub fn get_hourly_forecasts(
    &self,
    period: i8
) -> Result<Vec<HourlyForecast>, Box<dyn Error>>
[src]

Get Hourly forecasts for a given period

Parameters:

  • period: A valid accuweather forecasts period in hours as integrer. Can be 1, 12, 24, 72, 120.

Returns a Result with either a Vec of HourlyForecast or the generated error

Example

 let api_key = "abcdefg".to_string();
 let client = accuweather::Accuweather::new(api_key, Some(12345), None);
 client.get_hourly_forecasts(12);
 let forecast_errors = client.get_hourly_forecasts(5);
 assert!(forecast_errors.is_err());

pub fn get_daily_forecasts(
    &self,
    period: i8
) -> Result<DailyForecastsAnswer, Box<dyn Error>>
[src]

Get Daily forecasts for a given period

Parameters:

  • period: A valid accuweather forecasts period in hours as integrer. Can be 1, 5, 10, 15.

Returns a Result with either a DailyForecastAnswer or the generated error

Example

 let api_key = "abcdefg".to_string();
 let client = accuweather::Accuweather::new(api_key, Some(12345), None);
 client.get_daily_forecasts(5);
 let forecast_errors = client.get_daily_forecasts(6);
 assert!(forecast_errors.is_err());

pub fn get_current_conditions(
    &self
) -> Result<Vec<CurrentCondition>, Box<dyn Error>>
[src]

Get current conditions for location

Returns a Result with either a Vec of CurrentCondition (with 1 entry) or the generated error

Example

 let api_key = "abcdefg".to_string();
 let client = accuweather::Accuweather::new(api_key, Some(12345), Some("fr-fr".to_string()));
 client.get_current_conditions();

Trait Implementations

impl Debug for Accuweather[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

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

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