From c62bcab28fcc2939320f9cff617b8bb7af0daf76 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 16 Aug 2022 14:22:04 +0200 Subject: [PATCH] use random uid --- Cargo.lock | 11 +++++++++++ Cargo.toml | 7 +++++++ src/ics.rs | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e232722..f4d6d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,7 @@ dependencies = [ "reqwest", "scraper", "tokio", + "uuid", ] [[package]] @@ -1438,6 +1439,16 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "uuid" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +dependencies = [ + "getrandom 0.2.7", + "rand 0.8.5", +] + [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index b6bc33b..ecc5248 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,10 @@ scraper = "0.13.0" regex = "1" chrono = "0.4" ics = "0.5" + +[dependencies.uuid] +version = "1.1.2" +features = [ + "v4", # Lets you generate random UUIDs + "fast-rng", # Use a faster (but still sufficiently random) RNG +] diff --git a/src/ics.rs b/src/ics.rs index da3c140..5e1717c 100644 --- a/src/ics.rs +++ b/src/ics.rs @@ -8,22 +8,28 @@ pub fn export(courses: Vec, filename: &str) { // Create events which contains the information regarding the course for course in courses { - let mut event = Event::new("uid", "dtstamp"); + let mut event = Event::new(uuid::Uuid::new_v4().to_string(), dt_ical(chrono::Utc::now())); // Public event event.push(Class::public()); + // Consume actual time event.push(Transp::opaque()); + // Professor's name if course.professor.is_some() { event.push(Description::new(course.professor.unwrap())); } + // Start time of the course event.push(DtStart::new(dt_ical(course.dtstart.unwrap()))); + // End time of the course event.push(DtEnd::new(dt_ical(course.dtend.unwrap()))); + // Room location event.push(Location::new(course.room)); + // Course's name event.push(Summary::new(course.name));