unitore 0.1.0

Feed reader with the ability to set updates frequency.
Documentation
use std::{ fs::OpenOptions, io::{BufReader, Read} };

use serde::Deserialize;

#[ derive( Debug, Deserialize ) ]
pub struct FeedConfig
{
//   pub name : String,
  #[serde(with = "humantime_serde")]
  pub period : std::time::Duration,
  pub link : String,
}

#[ derive( Debug, Deserialize ) ]
pub struct Feeds
{
  pub config : Vec< FeedConfig >
}

pub fn read_feed_config() -> Result< Vec< FeedConfig >, Box< dyn std::error::Error > >
{
  let path = format!( "./test_feed_list.toml" );

  let read_file = OpenOptions::new().read( true ).open( &path )?;
  let mut reader = BufReader::new( read_file );
  let mut buffer: Vec< u8 > = Vec::new();
  reader.read_to_end( &mut buffer )?;

  let feeds : Feeds = toml::from_str( &String::from_utf8( buffer )? )?;

  println!( "{:#?}", feeds );

  Ok( feeds.config )
}