@@ -8,12 +8,12 @@ use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Ur
88use hyper_rustls:: HttpsConnector ;
99use libflate:: gzip;
1010use log:: { error, trace, warn} ;
11- use once_cell:: sync:: Lazy ;
1211use percent_encoding:: { percent_encode, CONTROLS } ;
1312use serde_json:: Value ;
1413
1514use std:: sync:: atomic:: Ordering ;
1615use std:: sync:: atomic:: { AtomicBool , AtomicU16 } ;
16+ use std:: sync:: LazyLock ;
1717use std:: { io, result:: Result } ;
1818
1919use crate :: dbg_msg;
@@ -30,12 +30,12 @@ const REDDIT_SHORT_URL_BASE_HOST: &str = "redd.it";
3030const ALTERNATIVE_REDDIT_URL_BASE : & str = "https://www.reddit.com" ;
3131const ALTERNATIVE_REDDIT_URL_BASE_HOST : & str = "www.reddit.com" ;
3232
33- pub static HTTPS_CONNECTOR : Lazy < HttpsConnector < HttpConnector > > =
34- Lazy :: new ( || hyper_rustls:: HttpsConnectorBuilder :: new ( ) . with_native_roots ( ) . https_only ( ) . enable_http2 ( ) . build ( ) ) ;
33+ pub static HTTPS_CONNECTOR : LazyLock < HttpsConnector < HttpConnector > > =
34+ LazyLock :: new ( || hyper_rustls:: HttpsConnectorBuilder :: new ( ) . with_native_roots ( ) . https_only ( ) . enable_http2 ( ) . build ( ) ) ;
3535
36- pub static CLIENT : Lazy < Client < HttpsConnector < HttpConnector > > > = Lazy :: new ( || Client :: builder ( ) . build :: < _ , Body > ( HTTPS_CONNECTOR . clone ( ) ) ) ;
36+ pub static CLIENT : LazyLock < Client < HttpsConnector < HttpConnector > > > = LazyLock :: new ( || Client :: builder ( ) . build :: < _ , Body > ( HTTPS_CONNECTOR . clone ( ) ) ) ;
3737
38- pub static OAUTH_CLIENT : Lazy < ArcSwap < Oauth > > = Lazy :: new ( || {
38+ pub static OAUTH_CLIENT : LazyLock < ArcSwap < Oauth > > = LazyLock :: new ( || {
3939 let client = block_on ( Oauth :: new ( ) ) ;
4040 tokio:: spawn ( token_daemon ( ) ) ;
4141 ArcSwap :: new ( client. into ( ) )
@@ -154,7 +154,7 @@ async fn stream(url: &str, req: &Request<Body>) -> Result<Response<Body>, String
154154 let parsed_uri = url. parse :: < Uri > ( ) . map_err ( |_| "Couldn't parse URL" . to_string ( ) ) ?;
155155
156156 // Build the hyper client from the HTTPS connector.
157- let client: & Lazy < Client < _ , Body > > = & CLIENT ;
157+ let client: & LazyLock < Client < _ , Body > > = & CLIENT ;
158158
159159 let mut builder = Request :: get ( parsed_uri) ;
160160
@@ -222,7 +222,7 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
222222 let url = format ! ( "{base_path}{path}" ) ;
223223
224224 // Construct the hyper client from the HTTPS connector.
225- let client: & Lazy < Client < _ , Body > > = & CLIENT ;
225+ let client: & LazyLock < Client < _ , Body > > = & CLIENT ;
226226
227227 // Build request to Reddit. When making a GET, request gzip compression.
228228 // (Reddit doesn't do brotli yet.)
0 commit comments