From db76004e8275a57285da2bd7a80e3a0eab7552d9 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 26 Oct 2019 00:19:25 +0200 Subject: [PATCH] split ticker-update into libticker --- Cargo.lock | 11 +++++++++++ libticker/Cargo.toml | 11 +++++++++++ {ticker-update => libticker}/src/config.rs | 0 {ticker-update => libticker}/src/ics/mod.rs | 0 {ticker-update => libticker}/src/ics/parser.rs | 0 .../src/ics/tokenizer.rs | 0 libticker/src/lib.rs | 7 +++++++ {ticker-update => libticker}/src/model.rs | 0 {ticker-update => libticker}/src/schema.rs | 0 ticker-update/Cargo.toml | 1 + ticker-update/src/main.rs | 17 ++++++----------- 11 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 libticker/Cargo.toml rename {ticker-update => libticker}/src/config.rs (100%) rename {ticker-update => libticker}/src/ics/mod.rs (100%) rename {ticker-update => libticker}/src/ics/parser.rs (100%) rename {ticker-update => libticker}/src/ics/tokenizer.rs (100%) create mode 100644 libticker/src/lib.rs rename {ticker-update => libticker}/src/model.rs (100%) rename {ticker-update => libticker}/src/schema.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 166cb74..35a46a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,6 +503,16 @@ name = "libc" version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libticker" +version = "0.1.0" +dependencies = [ + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "linked-hash-map" version = "0.5.2" @@ -1169,6 +1179,7 @@ dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "diesel 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libticker 0.1.0", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/libticker/Cargo.toml b/libticker/Cargo.toml new file mode 100644 index 0000000..cb1568f --- /dev/null +++ b/libticker/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "libticker" +version = "0.1.0" +authors = ["Astro "] +edition = "2018" + +[dependencies] +diesel = { version = "~1", features = ["postgres", "chrono"] } +chrono = "~0.4" +serde = { version = "~1.0", features = ["derive"] } +serde_yaml = "~0.8" diff --git a/ticker-update/src/config.rs b/libticker/src/config.rs similarity index 100% rename from ticker-update/src/config.rs rename to libticker/src/config.rs diff --git a/ticker-update/src/ics/mod.rs b/libticker/src/ics/mod.rs similarity index 100% rename from ticker-update/src/ics/mod.rs rename to libticker/src/ics/mod.rs diff --git a/ticker-update/src/ics/parser.rs b/libticker/src/ics/parser.rs similarity index 100% rename from ticker-update/src/ics/parser.rs rename to libticker/src/ics/parser.rs diff --git a/ticker-update/src/ics/tokenizer.rs b/libticker/src/ics/tokenizer.rs similarity index 100% rename from ticker-update/src/ics/tokenizer.rs rename to libticker/src/ics/tokenizer.rs diff --git a/libticker/src/lib.rs b/libticker/src/lib.rs new file mode 100644 index 0000000..ed002ba --- /dev/null +++ b/libticker/src/lib.rs @@ -0,0 +1,7 @@ +#[macro_use] +extern crate diesel; + +pub mod config; +pub mod ics; +pub mod model; +pub mod schema; diff --git a/ticker-update/src/model.rs b/libticker/src/model.rs similarity index 100% rename from ticker-update/src/model.rs rename to libticker/src/model.rs diff --git a/ticker-update/src/schema.rs b/libticker/src/schema.rs similarity index 100% rename from ticker-update/src/schema.rs rename to libticker/src/schema.rs diff --git a/ticker-update/Cargo.toml b/ticker-update/Cargo.toml index 4301d7d..f2832a3 100644 --- a/ticker-update/Cargo.toml +++ b/ticker-update/Cargo.toml @@ -12,3 +12,4 @@ serde = { version = "~1.0", features = ["derive"] } serde_yaml = "~0.8" num_cpus = "~1" crossbeam = "~0.7" +libticker = { path = "../libticker" } diff --git a/ticker-update/src/main.rs b/ticker-update/src/main.rs index 6c5486b..16dd2bb 100644 --- a/ticker-update/src/main.rs +++ b/ticker-update/src/main.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate diesel; - use std::mem::replace; use std::io::Read; use std::fs::read_to_string; @@ -10,14 +7,12 @@ use chrono::offset::Utc; use reqwest::header::{IF_NONE_MATCH, IF_MODIFIED_SINCE, ETAG, LAST_MODIFIED, USER_AGENT}; use diesel::{Connection, pg::PgConnection, prelude::*}; -mod config; -use config::{Config, CalendarOptions}; -mod schema; -use schema::{calendars::dsl::calendars}; -mod model; -use model::{Calendar, NewCalendar, Event}; -mod ics; -use ics::{Parser, Object, Timestamp, GetValue}; +use libticker::{ + config::{Config, CalendarOptions}, + schema::{self, calendars::dsl::calendars}, + model::{Calendar, NewCalendar, Event}, + ics::{Parser, Object, Timestamp, GetValue}, +}; fn extract_vevent_objs(results: &mut Vec, mut obj: Object) { let children = replace(&mut obj.children, vec![]);