mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: add Connection methods, enabling making 'inner' private
This commit is contained in:
parent
1ea1f0b749
commit
c28e764929
2 changed files with 28 additions and 8 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue