[−][src]Struct accuweather::Accuweather
Fields
client: Client
api_key: String
location: Option<i32>
language: String
Methods
impl Accuweather
[src]
pub fn new(
api_key: String,
location: Option<i32>,
language: Option<String>
) -> Self
[src]
api_key: String,
location: Option<i32>,
language: Option<String>
) -> Self
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
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]
&self,
period: i8
) -> Result<Vec<HourlyForecast>, Box<dyn Error>>
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]
&self,
period: i8
) -> Result<DailyForecastsAnswer, Box<dyn Error>>
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]
&self
) -> Result<Vec<CurrentCondition>, Box<dyn Error>>
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
Auto Trait Implementations
impl Send for Accuweather
impl Unpin for Accuweather
impl Sync for Accuweather
impl !UnwindSafe for Accuweather
impl !RefUnwindSafe for Accuweather
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,