scuffle_http/
extensions.rs

1//! HTTP extensions that this crate provides.
2
3use std::ops::Deref;
4
5#[cfg(feature = "webtransport")]
6pub use crate::backend::h3::webtransport::WebTransportSession;
7
8/// This extension is always present on the request and contains the remote address of the client.
9#[derive(Clone, Debug)]
10pub struct ClientAddr(pub std::net::SocketAddr);
11
12impl Deref for ClientAddr {
13    type Target = std::net::SocketAddr;
14
15    fn deref(&self) -> &Self::Target {
16        &self.0
17    }
18}
19
20/// This extension is present on the request when the client has provided one or multiple TLS client
21/// certificates.
22#[derive(Clone, Debug)]
23#[cfg(feature = "tls-rustls")]
24pub struct ClientIdentity(pub std::sync::Arc<Vec<tokio_rustls::rustls::pki_types::CertificateDer<'static>>>);
25
26#[cfg(feature = "tls-rustls")]
27impl Deref for ClientIdentity {
28    type Target = std::sync::Arc<Vec<tokio_rustls::rustls::pki_types::CertificateDer<'static>>>;
29
30    fn deref(&self) -> &Self::Target {
31        &self.0
32    }
33}