actix_tls/connect/
connection.rs1use super::Host;
2
3#[derive(Debug)]
5pub struct Connection<R, IO> {
6 pub(crate) req: R,
7 pub(crate) io: IO,
8}
9
10impl_more::impl_deref_and_mut!(<R, IO> in Connection<R, IO> => io: IO);
11
12impl<R, IO> Connection<R, IO> {
13 pub fn new(req: R, io: IO) -> Self {
15 Self { req, io }
16 }
17}
18
19impl<R, IO> Connection<R, IO> {
20 pub fn into_parts(self) -> (IO, R) {
22 (self.io, self.req)
23 }
24
25 pub fn replace_io<IO2>(self, io: IO2) -> (IO, Connection<R, IO2>) {
27 (self.io, Connection { io, req: self.req })
28 }
29
30 pub fn io_ref(&self) -> &IO {
32 &self.io
33 }
34
35 pub fn io_mut(&mut self) -> &mut IO {
37 &mut self.io
38 }
39
40 pub fn request(&self) -> &R {
42 &self.req
43 }
44}
45
46impl<R: Host, IO> Connection<R, IO> {
47 pub fn hostname(&self) -> &str {
49 self.req.hostname()
50 }
51}