mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-30 18:42:52 +01:00
remove From<OffsetDateTime>
impl from HttpDate
fully removes time crate from public api of -http
This commit is contained in:
parent
1281a748d0
commit
f66774e30b
3
.cargo/config.toml
Normal file
3
.cargo/config.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[alias]
|
||||
chk = "hack check --workspace --tests --examples"
|
||||
lint = "hack --clean-per-run clippy --workspace --tests --examples"
|
@ -1,18 +1,20 @@
|
||||
use std::fmt::{self, Display};
|
||||
use std::io::Write;
|
||||
use std::str::FromStr;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use std::{
|
||||
fmt,
|
||||
io::Write,
|
||||
str::FromStr,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use bytes::buf::BufMut;
|
||||
use bytes::BytesMut;
|
||||
use http::header::{HeaderValue, InvalidHeaderValue};
|
||||
use time::{offset, OffsetDateTime, PrimitiveDateTime};
|
||||
use time::{OffsetDateTime, PrimitiveDateTime, UtcOffset};
|
||||
|
||||
use crate::error::ParseError;
|
||||
use crate::header::IntoHeaderValue;
|
||||
use crate::time_parser;
|
||||
|
||||
/// A timestamp with HTTP formatting and parsing
|
||||
/// A timestamp with HTTP formatting and parsing.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct HttpDate(OffsetDateTime);
|
||||
|
||||
@ -27,18 +29,12 @@ impl FromStr for HttpDate {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for HttpDate {
|
||||
impl fmt::Display for HttpDate {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.0.format("%a, %d %b %Y %H:%M:%S GMT"), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OffsetDateTime> for HttpDate {
|
||||
fn from(dt: OffsetDateTime) -> HttpDate {
|
||||
HttpDate(dt)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SystemTime> for HttpDate {
|
||||
fn from(sys: SystemTime) -> HttpDate {
|
||||
HttpDate(PrimitiveDateTime::from(sys).assume_utc())
|
||||
@ -54,7 +50,7 @@ impl IntoHeaderValue for HttpDate {
|
||||
wrt,
|
||||
"{}",
|
||||
self.0
|
||||
.to_offset(offset!(UTC))
|
||||
.to_offset(UtcOffset::UTC)
|
||||
.format("%a, %d %b %Y %H:%M:%S GMT")
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -7,7 +7,7 @@ digraph {
|
||||
}
|
||||
|
||||
"actix-codec" -> { "actix-rt" "actix-service" "local-channel" "tokio" }
|
||||
"actix-utils" -> { "actix-rt" "actix-service" "local-waker" }
|
||||
"actix-utils" -> { "local-waker" }
|
||||
"actix-tracing" -> { "actix-service" }
|
||||
"actix-tls" -> { "actix-service" "actix-codec" "actix-utils" "actix-rt" }
|
||||
"actix-server" -> { "actix-service" "actix-rt" "actix-codec" "actix-utils" "tokio" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user