From 4444f64ee98f314938a383b4dfdf3cd74fd7e717 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 Apr 2023 07:25:24 +0000 Subject: fix(context): fix async sharing --- src/context/error.rs | 18 ++++++------------ src/context/hook.rs | 17 +++++++---------- src/context/route.rs | 18 ++++++++---------- 3 files changed, 21 insertions(+), 32 deletions(-) (limited to 'src/context') diff --git a/src/context/error.rs b/src/context/error.rs index eb1e00e..a9a4b85 100644 --- a/src/context/error.rs +++ b/src/context/error.rs @@ -17,24 +17,18 @@ // SPDX-License-Identifier: GPL-3.0-only use openssl::x509::X509; -use tokio::net::TcpStream; use url::Url; #[allow(clippy::module_name_repetitions)] -pub struct ErrorContext<'a> { - pub tcp: &'a TcpStream, - pub url: &'a Url, - pub certificate: &'a Option, +pub struct ErrorContext { + pub url: Url, + pub certificate: Option, } -impl<'a> ErrorContext<'a> { - pub const fn new( - tcp: &'a TcpStream, - url: &'a Url, - certificate: &'a Option, - ) -> Self { +impl ErrorContext { + #[must_use] + pub const fn new(url: Url, certificate: Option) -> Self { Self { - tcp, url, certificate, } diff --git a/src/context/hook.rs b/src/context/hook.rs index 44804fa..736696f 100644 --- a/src/context/hook.rs +++ b/src/context/hook.rs @@ -18,26 +18,23 @@ use matchit::Params; use openssl::x509::X509; -use tokio::net::TcpStream; use url::Url; #[allow(clippy::module_name_repetitions)] pub struct HookContext<'a> { - pub tcp: &'a TcpStream, - pub url: &'a Url, - pub params: Option<&'a Params<'a, 'a>>, - pub certificate: &'a Option, + pub url: Url, + pub params: Option>, + pub certificate: Option, } impl<'a> HookContext<'a> { + #[must_use] pub const fn new( - tcp: &'a TcpStream, - url: &'a Url, - params: Option<&'a Params<'a, 'a>>, - certificate: &'a Option, + url: Url, + params: Option>, + certificate: Option, ) -> Self { Self { - tcp, url, params, certificate, diff --git a/src/context/route.rs b/src/context/route.rs index 61eca0c..b3b105d 100644 --- a/src/context/route.rs +++ b/src/context/route.rs @@ -18,26 +18,24 @@ use matchit::Params; use openssl::x509::X509; -use tokio::net::TcpStream; use url::Url; #[allow(clippy::module_name_repetitions)] +#[derive(Clone)] pub struct RouteContext<'a> { - pub tcp: &'a TcpStream, - pub url: &'a Url, - pub params: &'a Params<'a, 'a>, - pub certificate: &'a Option, + pub url: Url, + pub params: Params<'a, 'a>, + pub certificate: Option, } impl<'a> RouteContext<'a> { + #[must_use] pub const fn new( - tcp: &'a TcpStream, - url: &'a Url, - params: &'a Params<'a, 'a>, - certificate: &'a Option, + url: Url, + params: Params<'a, 'a>, + certificate: Option, ) -> Self { Self { - tcp, url, params, certificate, -- cgit v1.2.3