1+ use std:: fmt:: Display ;
2+ use std:: mem:: MaybeUninit ;
3+ use std:: pin:: Pin ;
4+ use std:: task:: { self , Poll } ;
5+
16use anyhow:: { Context , Result } ;
27use chrono:: { DateTime , Local , Utc } ;
38use futures:: Stream ;
49use http:: response:: Builder as HttpResponseBuilder ;
510use hyper:: body:: Body ;
611use hyper:: body:: Bytes ;
7- use std:: mem:: MaybeUninit ;
8- use std:: pin:: Pin ;
9- use std:: task:: { self , Poll } ;
1012use tokio:: io:: { AsyncRead , ReadBuf } ;
1113
1214use super :: file:: File ;
@@ -41,9 +43,9 @@ pub enum CacheControlDirective {
4143 SMaxAge ( u64 ) ,
4244}
4345
44- impl ToString for CacheControlDirective {
45- fn to_string ( & self ) -> String {
46- match & self {
46+ impl Display for CacheControlDirective {
47+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
48+ let string = match & self {
4749 Self :: MustRevalidate => String :: from ( "must-revalidate" ) ,
4850 Self :: NoCache => String :: from ( "no-cache" ) ,
4951 Self :: NoStore => String :: from ( "no-store" ) ,
@@ -53,7 +55,9 @@ impl ToString for CacheControlDirective {
5355 Self :: ProxyRavalidate => String :: from ( "proxy-revalidate" ) ,
5456 Self :: MaxAge ( age) => format ! ( "max-age={}" , age) ,
5557 Self :: SMaxAge ( age) => format ! ( "s-maxage={}" , age) ,
56- }
58+ } ;
59+
60+ write ! ( f, "{string}" )
5761 }
5862}
5963
0 commit comments