Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"fe593cc56f3ee808d1aabfa1ec4a541574131919ad584db3945e52394fc24e5f","COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.lock":"0f70a0939c56005d0ed387d7615992fc0bedac0a06c8ebdb1f56fa08d9b3d14e","Cargo.toml":"ee9b71204a40b472df65a32887ac831f56dbcca33ddf171561f4fd5234bf13b8","Cargo.toml.orig":"815601a12aaa7c4f8ee6f3b9734f4cabd9894680ddeca7cc612d8f63e1764914","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","README.md":"1703b78df7b46a4d02c3992d5cf6aeb6d6dd4686322db5d73a1a228291cb913c","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","src/lib.rs":"616c0843a1be3b5038f09aa25f31e23098e2e1a4f7c79b176f22cfb1792bc72b"},"package":"3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204"}
+6
View File
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "2584cff71daebd477afe241cf049d4ccf595b855"
},
"path_in_vcs": "crates/jiff-static"
}
+3
View File
@@ -0,0 +1,3 @@
This project is dual-licensed under the Unlicense and MIT licenses.
You may use this code under the terms of either license.
+132
View File
@@ -0,0 +1,132 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "defmt"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2953bfe4f93bbd20cc71198842756f77d161884c99ebbabc41d80231ded88d1"
dependencies = [
"bitflags",
"defmt-macros",
]
[[package]]
name = "defmt-macros"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad9c72e7ca2137e0dc3813245a0d282fd6daad32fd800af018306a9169b5fe8"
dependencies = [
"defmt-parser",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "defmt-parser"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
dependencies = [
"thiserror",
]
[[package]]
name = "jiff-core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09"
dependencies = [
"defmt",
]
[[package]]
name = "jiff-static"
version = "0.2.35"
dependencies = [
"jiff-core",
"jiff-tzdb",
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "jiff-tzdb"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fac314a64dc9a36e61a9eb4261a5e9bbfbc922b27e518af97bc32b926cf967"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.0",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
+72
View File
@@ -0,0 +1,72 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.70"
name = "jiff-static"
version = "0.2.35"
authors = ["Andrew Gallant <jamslam@gmail.com>"]
build = false
include = [
"/src/**/*.rs",
"COPYING",
"LICENSE-MIT",
"UNLICENSE",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Create static TimeZone values for Jiff (useful in core-only environments)."
homepage = "https://github.com/BurntSushi/jiff/tree/master/crates/jiff-static"
documentation = "https://docs.rs/jiff-tzdb"
readme = "README.md"
keywords = [
"date",
"time",
"static",
"zone",
"iana",
]
categories = ["date-and-time"]
license = "Unlicense OR MIT"
repository = "https://github.com/BurntSushi/jiff"
[features]
default = []
perf-inline = []
tz-fat = []
tzdb = ["dep:jiff-tzdb"]
[lib]
name = "jiff_static"
path = "src/lib.rs"
bench = false
proc-macro = true
[dependencies.jcore]
version = "0.1"
package = "jiff-core"
[dependencies.jiff-tzdb]
version = "0.1.6"
optional = true
[dependencies.proc-macro2]
version = "1.0.93"
[dependencies.quote]
version = "1.0.38"
[dependencies.syn]
version = "2.0.98"
+43
View File
@@ -0,0 +1,43 @@
[package]
name = "jiff-static"
version = "0.2.35" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
license = "Unlicense OR MIT"
homepage = "https://github.com/BurntSushi/jiff/tree/master/crates/jiff-static"
repository = "https://github.com/BurntSushi/jiff"
documentation = "https://docs.rs/jiff-tzdb"
description = "Create static TimeZone values for Jiff (useful in core-only environments)."
categories = ["date-and-time"]
keywords = ["date", "time", "static", "zone", "iana"]
workspace = "../.."
include = ["/src/**/*.rs", "COPYING", "LICENSE-MIT", "UNLICENSE"]
edition.workspace = true
rust-version.workspace = true
[lib]
name = "jiff_static"
bench = false
proc-macro = true
[features]
default = []
# This forces the jiff-tzdb crate to be included and makes the `get` proc macro
# available (which pulls from the bundled tzdb).
tzdb = ["dep:jiff-tzdb"]
# This fattens up the TZif data to contain more explicit transitions. This may
# improve the performance of time zone lookups.
#
# See the `tz-fat` feature in this repository's root `Cargo.toml` for more
# context.
tz-fat = []
# Equivalent to the eponymous feature in `jiff` proper. Except it isn't
# enabled by default here, since we don't really care about that level of
# perf at compile time.
perf-inline = []
[dependencies]
jcore = { package = "jiff-core", version = "0.1", path = "../jiff-core" }
jiff-tzdb = { version = "0.1.6", path = "../jiff-tzdb", optional = true }
proc-macro2 = "1.0.93"
quote = "1.0.38"
syn = "2.0.98"
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Andrew Gallant
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
jiff-static
===========
This is an optional dependency of `jiff` that embeds time zone data into your
binary via procedural macros. It unlocks the use case of creating a `TimeZone`
value in core-only environments without dynamic memory allocation.
Users should generally not depend on this directly, but instead use it
through Jiff. Namely, all of the procedural macros defined in this crate
are re-exported through Jiff's public API. For example, one can enable the
`static` or `static-tz` crate features in `jiff` to get `jiff::tz::get!` and
`jiff::tz::include!`.
**WARNING**: The `src/shared` directory in this crate is copied from the
`../src/shared` directory. This copy is managed by `jiff-cli generate shared`.
See the comments in the code for why this is done.
### Documentation
https://docs.rs/jiff-static
+24
View File
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
+498
View File
@@ -0,0 +1,498 @@
/*!
This crate provides macros for defining `static` data structures for Jiff.
The macros in this crate are re-exported in the [`jiff::tz`] sub-module.
Users should _not_ depend on this crate directly or import from it. Instead,
enable the `static` or `static-tz` features of Jiff and use the re-exports in
`jiff::tz`.
At present, the macros in this crate are limited to creating `TimeZone`
in a `const` context. This works by reading TZif data (e.g., from
`/usr/share/zoneinfo/America/New_York` or from [`jiff-tzdb`]) at compile
time and generating Rust source code that builds a `TimeZone`.
# Documentation
The macros defined in this crate are documented on their corresponding
re-exports in Jiff:
* `get` is documented at [`jiff::tz::get`].
* `include` is documented at [`jiff::tz::include`].
# Compatibility
The APIs required to build a `TimeZone` in a `const` context are exposed by
Jiff but not part of Jiff's public API for the purposes of semver (and do not
appear in `rustdoc`). The only guarantee provided by `jiff` and `jiff-static`
is that there is exactly one version of `jiff` that `jiff-static` works with.
Conventionally, this is indicated by the exact same version string. That is,
`jiff-static 0.2.2` is only guaranteed to work with `jiff 0.2.2`.
This compatibility constraint is managed by Jiff, so that you should never
need to worry about it. In particular, users should never directly depend on
this crate. Everything should be managed through the `jiff` crate.
[`jiff-tzdb`]: https://docs.rs/jiff-tzdb
[`jiff::tz`]: https://docs.rs/jiff/0.2/jiff/tz/index.html
[`jiff::tz::get`]: https://docs.rs/jiff/0.2/jiff/tz/macro.get.html
[`jiff::tz::include`]: https://docs.rs/jiff/0.2/jiff/tz/macro.include.html
*/
extern crate alloc;
extern crate proc_macro;
use proc_macro::TokenStream;
use quote::quote;
use jcore::tz::{posix, tzif, TimeZoneId};
// Public API docs are in Jiff.
#[proc_macro]
pub fn include(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input as Include);
proc_macro::TokenStream::from(input.quote())
}
// Public API docs are in Jiff.
#[cfg(feature = "tzdb")]
#[proc_macro]
pub fn get(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input as Get);
proc_macro::TokenStream::from(input.quote())
}
/// The entry point for the `include!` macro.
#[derive(Debug)]
struct Include {
tzif: tzif::MaybeNamedTimeZone,
}
impl Include {
fn from_path_only(path: &str) -> Result<Include, String> {
const NEEDLE: &str = "zoneinfo/";
let Some(zoneinfo) = path.rfind(NEEDLE) else {
return Err(format!(
"could not extract IANA time zone identifier from \
file path `{path}` \
(could not find `zoneinfo` in path), \
please provide IANA time zone identifier as second \
parameter",
));
};
let idstart = zoneinfo.saturating_add(NEEDLE.len());
let id = &path[idstart..];
Include::from_path_with_id(id, path)
}
fn from_path_with_id(id: &str, path: &str) -> Result<Include, String> {
let id = TimeZoneId::new_or_heap(id);
let data = std::fs::read(path)
.map_err(|e| format!("failed to read {path}: {e}"))?;
let tzif = tzif::TimeZone::parse(&data)
.map_err(|e| {
format!("failed to parse TZif data from {path}: {e}")
})?
.into_named(id);
Ok(Include { tzif })
}
fn quote(&self) -> proc_macro2::TokenStream {
self.tzif.quote()
}
}
impl syn::parse::Parse for Include {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Include> {
let lit1 = input.parse::<syn::LitStr>()?.value();
if !input.lookahead1().peek(syn::Token![,]) {
return Ok(
Include::from_path_only(&lit1).map_err(|e| input.error(e))?
);
}
input.parse::<syn::Token![,]>()?;
if input.is_empty() {
return Ok(
Include::from_path_only(&lit1).map_err(|e| input.error(e))?
);
}
let lit2 = input.parse::<syn::LitStr>()?.value();
// Permit optional trailing comma.
if input.lookahead1().peek(syn::Token![,]) {
input.parse::<syn::Token![,]>()?;
}
Ok(Include::from_path_with_id(&lit2, &lit1)
.map_err(|e| input.error(e))?)
}
}
/// The entry point for the `get!` macro.
#[cfg(feature = "tzdb")]
#[derive(Debug)]
struct Get {
tzif: tzif::MaybeNamedTimeZone,
}
#[cfg(feature = "tzdb")]
impl Get {
fn from_id(id: &str) -> Result<Get, String> {
let (id, data) = jiff_tzdb::get(id).ok_or_else(|| {
format!("could not find time zone `{id}` in bundled tzdb")
})?;
let id = TimeZoneId::statik(id);
let tzif = tzif::TimeZone::parse(&data)
.map_err(|e| {
format!("failed to parse TZif data from bundled `{id}`: {e}")
})?
.into_named(id);
Ok(Get { tzif })
}
fn quote(&self) -> proc_macro2::TokenStream {
self.tzif.quote()
}
}
#[cfg(feature = "tzdb")]
impl syn::parse::Parse for Get {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Get> {
let lit1 = input.parse::<syn::LitStr>()?.value();
if input.lookahead1().peek(syn::Token![,]) {
input.parse::<syn::Token![,]>()?;
}
Ok(Get::from_id(&lit1).map_err(|e| input.error(e))?)
}
}
// Everything below at this point is quasi-quoting the `shared` data type
// values into `static` data structures as Rust source code.
trait Quote {
fn quote(&self) -> proc_macro2::TokenStream;
}
impl Quote for tzif::MaybeNamedTimeZone {
fn quote(&self) -> proc_macro2::TokenStream {
let tzif::MaybeNamedTimeZone { ref name, ref tz } = *self;
let tzif::TimeZone {
version,
checksum,
ref designations,
ref posix_tz,
ref types,
ref transitions,
} = *tz;
// We are guaranteed to always have a name in this context.
let name = name.as_ref().unwrap().quote();
let designations = designations.iter().map(Quote::quote);
let posix_tz = posix_tz
.as_ref()
.map(|tz| {
let tz = tz.quote();
quote!(Some(#tz))
})
.unwrap_or_else(|| quote!(None));
let types = types.iter().map(tzif::LocalTimeType::quote);
let transitions = transitions.quote();
quote! {{
static __TZ_DESIGNATIONS: &[jiff::__jcore::tz::Abbreviation] = &[#(#designations),*];
static __TZ_INTERNAL: jiff::__jcore::tz::tzif::MaybeNamedTimeZone =
jiff::__jcore::tz::tzif::MaybeNamedTimeZone {
name: Some(#name),
tz: jiff::__jcore::tz::tzif::TimeZone {
version: #version,
checksum: #checksum,
designations: jiff::__jcore::util::MaybeStaticSlice::statik(__TZ_DESIGNATIONS),
posix_tz: #posix_tz,
types: jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#types),*]),
transitions: #transitions,
},
};
static TZ: jiff::tz::TimeZone =
jiff::tz::TimeZone::__internal_from_tzif(&__TZ_INTERNAL);
// SAFETY: Since we are guaranteed that the `TimeZone` is
// constructed above as a static TZif time zone, it follows
// that it is safe to memcpy's its internal representation.
//
// NOTE: We arrange things this way so that `jiff::tz::get!`
// can be used "by value" in most contexts. Basically, we
// "pin" the time zone to a static so that it has a guaranteed
// static lifetime. Otherwise, since `TimeZone` has a `Drop`
// impl, it's easy to run afoul of this and have it be dropped
// earlier than you like. Since this particular variant of
// `TimeZone` can always be memcpy'd internally, we just do
// this dance here to save the user from having to write out
// their own `static`.
//
// NOTE: It would be nice if we could make this `copy` routine
// safe, or at least panic if it's misused. But to do that, you
// need to know the time zone variant. And to know the time
// zone variant, you need to "look" at the tag in the pointer.
// And looking at the address of a pointer in a `const` context
// is precarious.
unsafe { TZ.copy() }
}}
}
}
impl Quote for tzif::Transitions {
fn quote(&self) -> proc_macro2::TokenStream {
let tzif::Transitions {
ref timestamps,
ref civil_starts,
ref civil_ends,
ref infos,
} = *self;
let timestamps = timestamps.iter().map(tzif::Timestamp::quote);
let civil_starts = civil_starts.iter().map(tzif::DateTime::quote);
let civil_ends = civil_ends.iter().map(tzif::DateTime::quote);
let infos = infos.iter().map(tzif::TransitionInfo::quote);
quote! {
jiff::__jcore::tz::tzif::Transitions {
timestamps: jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#timestamps),*]),
civil_starts: jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#civil_starts),*]),
civil_ends: jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#civil_ends),*]),
infos: jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#infos),*]),
}
}
}
}
impl Quote for tzif::LocalTimeType {
fn quote(&self) -> proc_macro2::TokenStream {
let tzif::LocalTimeType { offset, dst, designation, indicator } =
*self;
let offset = offset.quote();
let dst = dst.quote();
let indicator = indicator.quote();
quote! {
jiff::__jcore::tz::tzif::LocalTimeType {
offset: #offset,
dst: #dst,
designation: #designation,
indicator: #indicator,
}
}
}
}
impl Quote for tzif::Indicator {
fn quote(&self) -> proc_macro2::TokenStream {
match *self {
tzif::Indicator::LocalWall => quote! {
jiff::__jcore::tz::tzif::Indicator::LocalWall
},
tzif::Indicator::LocalStandard => quote! {
jiff::__jcore::tz::tzif::Indicator::LocalStandard
},
tzif::Indicator::UTStandard => quote! {
jiff::__jcore::tz::tzif::Indicator::UTStandard
},
}
}
}
impl Quote for tzif::TransitionInfo {
fn quote(&self) -> proc_macro2::TokenStream {
let tzif::TransitionInfo { type_index, kind } = *self;
let kind = kind.quote();
quote! {
jiff::__jcore::tz::tzif::TransitionInfo {
type_index: #type_index,
kind: #kind,
}
}
}
}
impl Quote for tzif::TransitionKind {
fn quote(&self) -> proc_macro2::TokenStream {
match *self {
tzif::TransitionKind::Unambiguous => quote! {
jiff::__jcore::tz::tzif::TransitionKind::Unambiguous
},
tzif::TransitionKind::Gap => quote! {
jiff::__jcore::tz::tzif::TransitionKind::Gap
},
tzif::TransitionKind::Fold => quote! {
jiff::__jcore::tz::tzif::TransitionKind::Fold
},
}
}
}
impl Quote for tzif::DateTime {
fn quote(&self) -> proc_macro2::TokenStream {
let year = self.year();
let month = self.month();
let day = self.day();
let hour = self.hour();
let minute = self.minute();
let second = self.second();
quote! {
jiff::__jcore::tz::tzif::DateTime::new(jiff::__jcore::civil::datetime(
#year,
#month,
#day,
#hour,
#minute,
#second,
0
))
}
}
}
impl Quote for posix::TimeZone {
fn quote(&self) -> proc_macro2::TokenStream {
let posix::TimeZone { ref std_abbrev, ref std_offset, ref dst } =
*self;
let std_abbrev = std_abbrev.quote();
let std_offset = std_offset.quote();
let dst = dst
.as_ref()
.map(|dst| {
let dst = dst.quote();
quote!(Some(#dst))
})
.unwrap_or_else(|| quote!(None));
quote! {
jiff::__jcore::tz::posix::TimeZone {
std_abbrev: #std_abbrev,
std_offset: #std_offset,
dst: #dst,
}
}
}
}
impl Quote for posix::Dst {
fn quote(&self) -> proc_macro2::TokenStream {
let posix::Dst { ref abbrev, ref offset, ref rule } = *self;
let abbrev = abbrev.quote();
let offset = offset.quote();
let rule = rule.quote();
quote! {
jiff::__jcore::tz::posix::Dst {
abbrev: #abbrev,
offset: #offset,
rule: #rule,
}
}
}
}
impl Quote for posix::Rule {
fn quote(&self) -> proc_macro2::TokenStream {
let start = self.start.quote();
let end = self.end.quote();
quote! {
jiff::__jcore::tz::posix::Rule { start: #start, end: #end }
}
}
}
impl Quote for posix::DayTime {
fn quote(&self) -> proc_macro2::TokenStream {
let posix::DayTime { ref date, ref time } = *self;
let date = date.quote();
let time = time.quote();
quote! {
jiff::__jcore::tz::posix::DayTime { date: #date, time: #time }
}
}
}
impl Quote for posix::Day {
fn quote(&self) -> proc_macro2::TokenStream {
match *self {
posix::Day::JulianOne(day) => quote! {
jiff::__jcore::tz::posix::Day::JulianOne(#day)
},
posix::Day::JulianZero(day) => quote! {
jiff::__jcore::tz::posix::Day::JulianZero(#day)
},
posix::Day::WeekdayOfMonth { month, week, weekday } => {
let weekday = weekday.quote();
quote! {
jiff::__jcore::tz::posix::Day::WeekdayOfMonth {
month: #month,
week: #week,
weekday: #weekday,
}
}
}
}
}
}
impl Quote for jcore::civil::Weekday {
fn quote(&self) -> proc_macro2::TokenStream {
use jcore::civil::Weekday::*;
match *self {
Sunday => quote!(jiff::__jcore::civil::Weekday::Sunday),
Monday => quote!(jiff::__jcore::civil::Weekday::Monday),
Tuesday => quote!(jiff::__jcore::civil::Weekday::Tuesday),
Wednesday => quote!(jiff::__jcore::civil::Weekday::Wednesday),
Thursday => quote!(jiff::__jcore::civil::Weekday::Thursday),
Friday => quote!(jiff::__jcore::civil::Weekday::Friday),
Saturday => quote!(jiff::__jcore::civil::Weekday::Saturday),
}
}
}
impl Quote for jcore::tz::posix::TransitionCivilTime {
fn quote(&self) -> proc_macro2::TokenStream {
let posix::TransitionCivilTime { second } = *self;
quote! {
jiff::__jcore::tz::posix::TransitionCivilTime { second: #second }
}
}
}
impl Quote for tzif::Timestamp {
fn quote(&self) -> proc_macro2::TokenStream {
let second = self.as_second();
quote! {
jiff::__jcore::tz::tzif::Timestamp::new(
jiff::__jcore::Timestamp::constant(#second, 0),
)
}
}
}
impl Quote for jcore::tz::Offset {
fn quote(&self) -> proc_macro2::TokenStream {
let seconds = self.seconds();
quote! {
jiff::__jcore::tz::Offset::constant_seconds(#seconds)
}
}
}
impl Quote for jcore::tz::Dst {
fn quote(&self) -> proc_macro2::TokenStream {
match *self {
jcore::tz::Dst::Yes => quote! { jiff::__jcore::tz::Dst::Yes },
jcore::tz::Dst::No => quote! { jiff::__jcore::tz::Dst::No },
}
}
}
impl<const N: usize> Quote for jcore::util::SmallStr<N> {
fn quote(&self) -> proc_macro2::TokenStream {
let s = self.as_str();
quote! {
jiff::__jcore::util::SmallStr::statik(#s)
}
}
}
impl<T: Quote + 'static> Quote for jcore::util::MaybeStaticSlice<T> {
fn quote(&self) -> proc_macro2::TokenStream {
let slice = self.as_slice().iter().map(Quote::quote);
quote! {{
jiff::__jcore::util::MaybeStaticSlice::statik(&[#(#slice),*])
}}
}
}