diff --git a/Cargo.lock b/Cargo.lock index ac8650b..d95e733 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,12 +85,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" - [[package]] name = "bumpalo" version = "3.12.0" @@ -172,7 +166,7 @@ version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ - "bitflags 1.3.2", + "bitflags", "clap_lex 0.2.4", "indexmap", "textwrap", @@ -180,11 +174,11 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.11" +version = "4.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" dependencies = [ - "bitflags 2.0.2", + "bitflags", "clap_derive", "clap_lex 0.3.3", "is-terminal", @@ -195,15 +189,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.9" +version = "4.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" +checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.10", ] [[package]] @@ -454,9 +447,9 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown", @@ -618,7 +611,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", "static_assertions", @@ -778,35 +771,11 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" dependencies = [ "unicode-ident", ] @@ -941,23 +910,23 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] name = "regex" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "rgb" @@ -970,9 +939,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" [[package]] name = "rustix" @@ -980,7 +949,7 @@ version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -1026,7 +995,7 @@ checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] @@ -1106,9 +1075,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.4" +version = "2.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c622ae390c9302e214c31013517c2061ecb2699935882c60a9b37f82f8625ae" +checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" dependencies = [ "proc-macro2", "quote", @@ -1160,7 +1129,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.10", ] [[package]] @@ -1175,18 +1144,18 @@ dependencies = [ [[package]] name = "tzf-rel" -version = "0.0.2022-g1" +version = "0.0.2023-b" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9740d99d1cf246ba7848086fdbebc8ce6adc64715e6e5edd4695985f8053064b" +checksum = "e305448914389c394ef4d3285688b6fa0f69602122c4a446acb39ff3e9669c65" [[package]] name = "tzf-rs" -version = "0.3.1" +version = "0.4.0" dependencies = [ "anyhow", "bytes", "cities-json", - "clap 4.1.11", + "clap 4.1.13", "criterion", "geometry-rs", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 323bee8..3ebce43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ license-file = "LICENSE" name = "tzf-rs" readme = "README.md" repository = "http://github.com/ringsaturn/tzf-rs" -version = "0.3.1" +version = "0.4.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,7 +21,7 @@ prost = "0.11" rand = "0.8.5" # tzf-rel = { git = "http://github.com/ringsaturn/tzf-rel", tag = "v0.0.2022-f5"} -tzf-rel = "0.0.2022-g1" +tzf-rel = "0.0.2023-b" # geometry-rs = { git = "http://github.com/ringsaturn/geometry-rs", tag = "v0.1.0"} geometry-rs = "0.1.2" diff --git a/src/gen/pb.rs b/src/gen/pb.rs index dd68373..88e4671 100644 --- a/src/gen/pb.rs +++ b/src/gen/pb.rs @@ -64,6 +64,8 @@ pub struct Timezones { /// Reduced data will toggle neighbor search as plan b #[prost(bool, tag = "2")] pub reduced: bool, + #[prost(string, tag = "3")] + pub version: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -89,6 +91,8 @@ pub struct CompressedTimezones { pub method: i32, #[prost(message, repeated, tag = "2")] pub timezones: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub version: ::prost::alloc::string::String, } /// PreindexTimezone tile item. /// @@ -117,6 +121,8 @@ pub struct PreindexTimezones { pub agg_zoom: i32, #[prost(message, repeated, tag = "3")] pub keys: ::prost::alloc::vec::Vec, + #[prost(string, tag = "4")] + pub version: ::prost::alloc::string::String, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] diff --git a/src/lib.rs b/src/lib.rs index 1534088..7026089 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,13 +55,17 @@ impl Item { #[derive(Debug)] pub struct Finder { all: Vec, + data_version: String, } impl Finder { /// `from_pb` is used when you can use your own timezone data, as long as /// it's compatible with Proto's desc. pub fn from_pb(tzs: gen::Timezones) -> Finder { - let mut f: Finder = Finder { all: vec![] }; + let mut f: Finder = Finder { + all: vec![], + data_version: tzs.version, + }; for tz in tzs.timezones.iter() { let mut polys: Vec = vec![]; @@ -167,6 +171,18 @@ impl Finder { } return ret; } + + /// Example: + /// + /// ```rust + /// use tzf_rs::Finder; + /// + /// let finder = Finder::new(); + /// println!("{:?}", finder.data_version()); + /// ``` + pub fn data_version(&self) -> &str { + return &self.data_version; + } } /// deg2num is used to convert longitude, latitude to [Slippy map tilenames] @@ -202,6 +218,7 @@ pub struct FuzzyFinder { min_zoom: i64, max_zoom: i64, all: HashMap<(i64, i64, i64), String>, // K: + data_version: String, } impl FuzzyFinder { @@ -210,6 +227,7 @@ impl FuzzyFinder { min_zoom: tzs.agg_zoom as i64, max_zoom: tzs.idx_zoom as i64, all: HashMap::new(), + data_version: tzs.version, }; for item in tzs.keys.iter() { f.all.insert( @@ -251,6 +269,18 @@ impl FuzzyFinder { } return ""; } + + /// Example: + /// + /// ```rust + /// use tzf_rs::FuzzyFinder; + /// + /// let finder = FuzzyFinder::new(); + /// println!("{:?}", finder.data_version()); + /// ``` + pub fn data_version(&self) -> &str { + return &self.data_version; + } } /// It's most recommend to use, combine both [Finder] and [FuzzyFinder]. @@ -304,4 +334,16 @@ impl DefaultFinder { pub fn timezonenames(&self) -> Vec<&str> { return self.finder.timezonenames(); } + + /// Example: + /// + /// ```rust + /// use tzf_rs::DefaultFinder; + /// + /// let finder = DefaultFinder::new(); + /// println!("{:?}", finder.data_version()); + /// ``` + pub fn data_version(&self) -> &str { + return &self.finder.data_version; + } } diff --git a/tzinfo.proto b/tzinfo.proto index d5780d6..1f929c9 100644 --- a/tzinfo.proto +++ b/tzinfo.proto @@ -54,6 +54,7 @@ message Timezone { message Timezones { repeated Timezone timezones = 1; bool reduced = 2; // Reduced data will toggle neighbor search as plan b + string version = 3; } enum CompressMethod { @@ -76,6 +77,7 @@ message CompressedTimezone { message CompressedTimezones { CompressMethod method = 1; repeated CompressedTimezone timezones = 2; + string version = 3; } // PreindexTimezone tile item. @@ -93,4 +95,5 @@ message PreindexTimezones { int32 idxZoom = 1; // which zoom value the tiles generated int32 aggZoom = 2; // which zoom value the tiles merge up with. repeated PreindexTimezone keys = 3; + string version = 4; }