mirror of
https://github.com/greatest-ape/aquatic.git
synced 2026-10-23 01:41:20 +00:00
aquatic_http: add Connection methods, enabling making 'inner' private
This commit is contained in:
1 parent
1ea1f0b749
commit
c28e764929
2 files changed
+28
-8
No files matched your search
@@ -191,7 +191,7 @@ impl <'a>TlsHandshakeMachine {
|
||||
}
|
||||
|
||||
|
||||
pub enum ConnectionInner {
|
||||
enum ConnectionInner {
|
||||
Established(EstablishedConnection),
|
||||
InProgress(TlsHandshakeMachine),
|
||||
}
|
||||
@@ -199,7 +199,7 @@ pub enum ConnectionInner {
|
||||
|
||||
pub struct Connection {
|
||||
pub valid_until: ValidUntil,
|
||||
pub inner: ConnectionInner,
|
||||
inner: ConnectionInner,
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,26 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_established(
|
||||
valid_until: ValidUntil,
|
||||
established: EstablishedConnection,
|
||||
) -> Self {
|
||||
Self {
|
||||
valid_until,
|
||||
inner: ConnectionInner::Established(established)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_in_progress(
|
||||
valid_until: ValidUntil,
|
||||
machine: TlsHandshakeMachine,
|
||||
) -> Self {
|
||||
Self {
|
||||
valid_until,
|
||||
inner: ConnectionInner::InProgress(machine)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_established(&mut self) -> Option<&mut EstablishedConnection> {
|
||||
if let ConnectionInner::Established(ref mut established) = self.inner {
|
||||
Some(established)
|
||||
|
||||
@@ -252,18 +252,18 @@ pub fn run_handshakes_and_read_requests(
|
||||
{
|
||||
match handshake_machine.establish_tls(){
|
||||
Ok(established) => {
|
||||
let connection = Connection {
|
||||
let connection = Connection::from_established(
|
||||
valid_until,
|
||||
inner: ConnectionInner::Established(established)
|
||||
};
|
||||
established
|
||||
);
|
||||
|
||||
connections.insert(poll_token, connection);
|
||||
},
|
||||
Err(TlsHandshakeMachineError::WouldBlock(machine)) => {
|
||||
let connection = Connection {
|
||||
let connection = Connection::from_in_progress(
|
||||
valid_until,
|
||||
inner: ConnectionInner::InProgress(machine)
|
||||
};
|
||||
machine
|
||||
);
|
||||
|
||||
connections.insert(poll_token, connection);
|
||||
|
||||
|
||||
Reference in new issue
Block a user