epw_rs

Struct EPWFile

Source
pub struct EPWFile {
    pub header: Header,
    pub data: WeatherData,
}

Fields§

§header: Header§data: WeatherData

Implementations§

Source§

impl EPWFile

Source

pub fn from_reader<R: BufRead>(reader: R) -> Result<Self, EPWParseError>

Construct an EPWFile instance from a buffered reader.

§Type Parameters
  • R: the type of the reader
§Parameters
  • reader: Reader that returns file contents.
§Returns

An initialized EPWReader or an EPWParseError

Source

pub fn from_path(path: &str) -> Result<Self, EPWParseError>

Create an EPWFile instance from a file path

§Parameters
  • path: Path to file on the filesystem
§Returns

An initialized EPWFile or an EPWParseError

Examples found in repository?
examples/example.rs (line 7)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn main() {
    let parsed = EPWFile::from_path("./data/USA_FL_Tampa_TMY2.epw");
    match parsed {
        Ok(epw) => {
            let location = epw.header.location;
            let data = epw.data;
            println!(
                "Location: {:.4}, {:.4} [{}, {}]",
                location.latitude,
                location.longitude,
                location.city,
                location.state_province_region
            );
            let max_temp = match data.dry_bulb_temperature.into_iter().reduce(f64::max) {
                Some(t) => t,
                None => panic!("Couldn't calculate max temperature"),
            };
            println!("Max Temperature: {:.2}°C", max_temp);
        }
        Err(e) => println!("{:?}", e),
    }
}

Trait Implementations§

Source§

impl Debug for EPWFile

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.