diff options
| author | Nathan Jaremko | 2018-11-19 10:36:42 -0500 | 
|---|---|---|
| committer | Nathan Jaremko | 2018-11-19 10:36:42 -0500 | 
| commit | 118b36cbf32024f16ab7db4f1ad0b1a29b7592f5 (patch) | |
| tree | f4d4b40f20ec10ec3526bdf239a1995e6830ac36 /src/structs.rs | |
| parent | 714e8ded029907c1d8639121a3d171344808a5d5 (diff) | |
| download | podcast-118b36cbf32024f16ab7db4f1ad0b1a29b7592f5.tar.bz2 | |
Upgrade to rust 2018
Diffstat (limited to 'src/structs.rs')
| -rw-r--r-- | src/structs.rs | 38 | 
1 files changed, 24 insertions, 14 deletions
| diff --git a/src/structs.rs b/src/structs.rs index e585677..a0d9bd7 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,6 +1,6 @@ -use actions::*; -use errors::*; -use utils::*; +use super::actions::*; +use super::utils::*; +use crate::errors::*;  use std::collections::BTreeSet;  use std::fs::{self, DirBuilder, File}; @@ -105,7 +105,8 @@ impl State {              // Check if a day has passed (86400 seconds) since last launch              if Utc::now()                  .signed_duration_since(state.last_run_time) -                .num_seconds() > 86400 +                .num_seconds() +                > 86400              {                  update_rss(&mut state);                  check_for_update(&state.version)?; @@ -186,9 +187,9 @@ impl Podcast {      #[allow(dead_code)]      pub fn from_url(url: &str) -> Result<Podcast> { -        Ok( -            Podcast::from(Channel::from_url(url).chain_err(|| UNABLE_TO_CREATE_CHANNEL_FROM_RESPONSE)?), -        ) +        Ok(Podcast::from( +            Channel::from_url(url).chain_err(|| UNABLE_TO_CREATE_CHANNEL_FROM_RESPONSE)?, +        ))      }      pub fn from_title(title: &str) -> Result<Podcast> { @@ -198,8 +199,10 @@ impl Podcast {          path.push(filename);          let file = File::open(&path).chain_err(|| UNABLE_TO_OPEN_FILE)?; -        Ok(Podcast::from(Channel::read_from(BufReader::new(file)) -            .chain_err(|| UNABLE_TO_CREATE_CHANNEL_FROM_FILE)?)) +        Ok(Podcast::from( +            Channel::read_from(BufReader::new(file)) +                .chain_err(|| UNABLE_TO_CREATE_CHANNEL_FROM_FILE)?, +        ))      }      pub fn delete(title: &str) -> Result<()> { @@ -284,7 +287,11 @@ impl Podcast {  impl Episode {      pub fn title(&self) -> Option<String> { -        Some(FILENAME_ESCAPE.replace_all(self.0.title()?, "_").to_string()) +        Some( +            FILENAME_ESCAPE +                .replace_all(self.0.title()?, "_") +                .to_string(), +        )      }      pub fn url(&self) -> Option<&str> { @@ -313,9 +320,11 @@ impl Episode {          if let Some(url) = self.url() {              if let Some(title) = self.title() { -                let mut filename = String::from(title); -                filename.push_str(self.extension() -                    .chain_err(|| "unable to retrieve extension")?); +                let mut filename = title; +                filename.push_str( +                    self.extension() +                        .chain_err(|| "unable to retrieve extension")?, +                );                  path.push(filename);                  if !path.exists() {                      println!("Downloading: {}", path.to_str().unwrap()); @@ -324,7 +333,8 @@ impl Episode {                      let mut content: Vec<u8> = Vec::new();                      resp.read_to_end(&mut content)                          .chain_err(|| UNABLE_TO_READ_RESPONSE_TO_END)?; -                    file.write_all(&content).chain_err(|| UNABLE_TO_WRITE_FILE)?; +                    file.write_all(&content) +                        .chain_err(|| UNABLE_TO_WRITE_FILE)?;                  } else {                      println!(                          "File already exists: {}", | 
