-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
99 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::config::*; | ||
use crate::course::*; | ||
use crate::download::*; | ||
pub struct Account { | ||
config: Config, | ||
remote_data: RemoteData, | ||
course: Vec<Course>, | ||
downloadfolders: Vec<DownloadFolder> | ||
} | ||
|
||
impl Account { | ||
pub fn new(st: &str) -> Self { | ||
let config = Config::read_file(st); | ||
let remote_data = RemoteData::new(&config.key, &config.canvas_url); | ||
let course = remote_data.get_course_list(); | ||
Self { | ||
config, | ||
remote_data, | ||
course, | ||
downloadfolders:Vec::new() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::fs::*; | ||
use std::io::*; | ||
#[derive(Serialize, Deserialize)] | ||
|
||
pub struct Config { | ||
pub key: String, | ||
pub local_place: String, | ||
pub canvas_url: String, | ||
} | ||
|
||
|
||
impl Config { | ||
pub fn print(&self) -> () { | ||
println!( | ||
"local_place={local_place},canvas_url={canvas_url}", | ||
local_place = self.local_place, | ||
canvas_url = self.canvas_url | ||
) | ||
} | ||
pub fn read_file(s:&str) -> Self { | ||
let file = File::open(s).unwrap(); | ||
let reader = BufReader::new(file); | ||
serde_json::from_reader(reader).expect("Error while reading config file") | ||
} | ||
pub fn new() -> Self { | ||
Self { | ||
key: "".to_string(), | ||
local_place: "".to_string(), | ||
canvas_url: "".to_string(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
mod download; | ||
mod my_key; | ||
mod course; | ||
// use futures::executor::block_on; | ||
use crate::download::RemoteData; | ||
mod config; | ||
mod account; | ||
|
||
fn main() { | ||
// println!("Hello, world!"); | ||
let x = RemoteData::new(); | ||
let mycourses=x.get_course_list(); | ||
// for course in mycourses{ | ||
// course.download_files(); | ||
// } | ||
|
||
let x = account::Account::new("/home/wznmickey/github/canvas_syncer/src/config.json"); | ||
} |