Merge branch 'humantime' into 'main'
Replace humantime_serde_option with upstream code Closes #396 See merge request tpo/core/arti!406
This commit is contained in:
commit
ff489ffde7
|
@ -1485,9 +1485,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
|||
|
||||
[[package]]
|
||||
name = "humantime-serde"
|
||||
version = "1.0.1"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058"
|
||||
checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c"
|
||||
dependencies = [
|
||||
"humantime 2.1.0",
|
||||
"serde",
|
||||
|
@ -3098,8 +3098,6 @@ name = "tor-basic-utils"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"educe",
|
||||
"humantime-serde",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -38,7 +38,7 @@ tor-persist = { path="../tor-persist", version = "0.1.0"}
|
|||
tor-proto = { path="../tor-proto", version = "0.1.0"}
|
||||
tor-rtcompat = { path="../tor-rtcompat", version = "0.1.0"}
|
||||
|
||||
humantime-serde = "1"
|
||||
humantime-serde = "1.1.1"
|
||||
derive_builder = "0.10.2"
|
||||
derive_more = "0.99"
|
||||
directories = "4"
|
||||
|
|
|
@ -17,7 +17,6 @@ use std::collections::HashMap;
|
|||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
pub use tor_basic_utils::humantime_serde_option;
|
||||
pub use tor_config::{CfgPath, ConfigBuildError, Reconfigure};
|
||||
|
||||
/// Types for configuring how Tor circuits are built.
|
||||
|
@ -77,20 +76,20 @@ pub struct StreamTimeoutConfig {
|
|||
/// to a host?
|
||||
#[builder(default = "default_connect_timeout()")]
|
||||
#[serde(with = "humantime_serde", default = "default_connect_timeout")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) connect_timeout: Duration,
|
||||
|
||||
/// How long should we wait before timing out when resolving a DNS record?
|
||||
#[builder(default = "default_dns_resolve_timeout()")]
|
||||
#[serde(with = "humantime_serde", default = "default_dns_resolve_timeout")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) resolve_timeout: Duration,
|
||||
|
||||
/// How long should we wait before timing out when resolving a DNS
|
||||
/// PTR record?
|
||||
#[builder(default = "default_dns_resolve_ptr_timeout()")]
|
||||
#[serde(with = "humantime_serde", default = "default_dns_resolve_ptr_timeout")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) resolve_ptr_timeout: Duration,
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,6 @@ categories = ["rust-patterns"] # We must put *something* here and this will do
|
|||
repository = "https://gitlab.torproject.org/tpo/core/arti.git/"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.103", features = ["derive"], optional = true }
|
||||
humantime-serde-crate = { package = "humantime-serde", version = "1", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["humantime-serde"]
|
||||
humantime-serde = ["humantime-serde-crate", "serde"]
|
||||
|
||||
[dev-dependencies]
|
||||
educe = "0.4.6"
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
//! Module to adaopt `humantime_serde` to `Option<Duration>`
|
||||
|
||||
use humantime_serde_crate::Serde as HtSerde;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// Serializes an `Option<Duration>` or `Option<SystemTime>` via the humantime crate.
|
||||
pub fn serialize<T, S>(d: &Option<T>, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
for<'a> HtSerde<&'a T>: Serialize,
|
||||
S: Serializer,
|
||||
{
|
||||
let nested: Option<HtSerde<&T>> = d.as_ref().map(Into::into);
|
||||
nested.serialize(s)
|
||||
}
|
||||
|
||||
/// Deserialize an `Option<Duration>` or `Option<SystemTime>` via the humantime crate.
|
||||
pub fn deserialize<'a, T, D>(d: D) -> Result<Option<T>, D::Error>
|
||||
where
|
||||
HtSerde<T>: Deserialize<'a>,
|
||||
D: Deserializer<'a>,
|
||||
{
|
||||
let got: Option<HtSerde<T>> = Deserialize::deserialize(d)?;
|
||||
Ok(got.map(HtSerde::into_inner))
|
||||
}
|
|
@ -41,9 +41,6 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
#[cfg(feature = "humantime-serde")]
|
||||
pub mod humantime_serde_option;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/// Function with the signature of `Debug::fmt` that just prints `".."`
|
||||
|
|
|
@ -36,7 +36,7 @@ bounded-vec-deque = "0.1"
|
|||
derive_builder = "0.10.2"
|
||||
educe = "0.4.6"
|
||||
futures = "0.3.14"
|
||||
humantime-serde = "1"
|
||||
humantime-serde = "1.1.1"
|
||||
itertools = "0.10.1"
|
||||
tracing = "0.1.18"
|
||||
pin-project = "1"
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//!
|
||||
//! Most types in this module are re-exported by `arti-client`.
|
||||
|
||||
use tor_basic_utils::humantime_serde_option;
|
||||
use tor_config::ConfigBuildError;
|
||||
|
||||
use derive_builder::Builder;
|
||||
|
@ -121,7 +120,7 @@ pub struct PreemptiveCircuitConfig {
|
|||
/// available for that port?
|
||||
#[builder(default = "default_preemptive_duration()")]
|
||||
#[serde(with = "humantime_serde", default = "default_preemptive_duration")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) prediction_lifetime: Duration,
|
||||
|
||||
/// How many available circuits should we try to have, at minimum, for each
|
||||
|
@ -150,7 +149,7 @@ pub struct CircuitTiming {
|
|||
/// it out for new requests?
|
||||
#[builder(default = "default_max_dirtiness()")]
|
||||
#[serde(with = "humantime_serde", default = "default_max_dirtiness")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) max_dirtiness: Duration,
|
||||
|
||||
/// When a circuit is requested, we stop retrying new circuits
|
||||
|
@ -158,7 +157,7 @@ pub struct CircuitTiming {
|
|||
// TODO: Impose a maximum or minimum?
|
||||
#[builder(default = "default_request_timeout()")]
|
||||
#[serde(with = "humantime_serde", default = "default_request_timeout")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) request_timeout: Duration,
|
||||
|
||||
/// When a circuit is requested, we stop retrying new circuits after
|
||||
|
@ -173,7 +172,7 @@ pub struct CircuitTiming {
|
|||
/// request.
|
||||
#[builder(default = "default_request_loyalty()")]
|
||||
#[serde(with = "humantime_serde", default = "default_request_loyalty")]
|
||||
#[builder(attrs(serde(with = "humantime_serde_option")))]
|
||||
#[builder(attrs(serde(with = "humantime_serde::option")))]
|
||||
pub(crate) request_loyalty: Duration,
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ serde = { version = "1.0.103", features = ["derive"] }
|
|||
signature = "1"
|
||||
thiserror = "1"
|
||||
time = { version = "0.3", features = ["formatting", "parsing"] }
|
||||
humantime-serde = "1"
|
||||
humantime-serde = "1.1.1"
|
||||
|
||||
[dev-dependencies]
|
||||
futures-await-test = "0.3.0"
|
||||
|
|
|
@ -32,7 +32,7 @@ tor-units = { path="../tor-units", version = "0.1.0"}
|
|||
derive_builder = "0.10.2"
|
||||
educe = "0.4.6"
|
||||
futures = "0.3.14"
|
||||
humantime-serde = "1"
|
||||
humantime-serde = "1.1.1"
|
||||
itertools = "0.10.1"
|
||||
pin-project = "1"
|
||||
rand = "0.8"
|
||||
|
|
|
@ -53,6 +53,10 @@ tor-netdoc:
|
|||
new-api (experimental only): Can modify the set of relays in an unverified
|
||||
consensus.
|
||||
|
||||
|
||||
tor-netdoc:
|
||||
api-break: changed the return type of GenericRouterStatus::version()
|
||||
|
||||
tor-basic-utils:
|
||||
|
||||
Remove `humantime_serde_option` module.
|
||||
(Use `humantime_serde::option` instead.)
|
||||
|
|
Loading…
Reference in New Issue