mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
net: Stop using both versions of the time
crate in the cookie code (#33260)
`std::time` is good enough for us here. `cookie` is using `time 0.3`, but Servo can convert to standard library types when getting data from `cookie`. This reduces our direct dependencies and removes more use of the very old `time 0.1` series. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
1e9344cb5c
commit
6f333a8e29
9 changed files with 29 additions and 95 deletions
|
@ -20,7 +20,6 @@
|
|||
//! * `hyper::Method`
|
||||
//! * `hyper::Uri`
|
||||
//! * `mime::Mime`
|
||||
//! * `time::Tm`
|
||||
//!
|
||||
//! # How do I use a data type with a `HeaderMap` member with Serde?
|
||||
//!
|
||||
|
@ -78,7 +77,6 @@ use serde::de::{self, Error, MapAccess, SeqAccess, Visitor};
|
|||
use serde::ser::{SerializeMap, SerializeSeq};
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_bytes::{ByteBuf, Bytes};
|
||||
use time::{strptime, Tm};
|
||||
|
||||
/// Deserialises a `T` value with a given deserializer.
|
||||
///
|
||||
|
@ -604,43 +602,6 @@ impl<'de> Visitor<'de> for StatusVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for De<Tm> {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct TmVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for TmVisitor {
|
||||
type Value = De<Tm>;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(formatter, "a date and time according to RFC 3339")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
strptime(v, "%Y-%m-%dT%H:%M:%SZ")
|
||||
.map(De::new)
|
||||
.map_err(|e| E::custom(e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_string(TmVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Serialize for Ser<'a, Tm> {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.serialize_str(&self.v.rfc3339().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for De<Uri> {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue