socket: beautify lifetime

master
occheung 2020-12-01 16:22:08 +08:00
parent c50894ad7f
commit 4f8b273e86
1 changed files with 23 additions and 23 deletions

View File

@ -57,22 +57,22 @@ pub(crate) enum TlsState {
SERVER_CONNECTED, SERVER_CONNECTED,
} }
pub struct TlsSocket<'s> pub struct TlsSocket<'b>
{ {
tcp_handle: SocketHandle, tcp_handle: SocketHandle,
rng: &'s mut dyn crate::TlsRng, rng: &'b mut dyn crate::TlsRng,
session: RefCell<Session<'s>>, session: RefCell<Session<'b>>,
} }
impl<'s> TlsSocket<'s> { impl<'b> TlsSocket<'b> {
pub fn new<'a, 'b, 'c>( pub fn new<'a, 'c>(
sockets: &mut SocketSet<'a, 'b, 'c>, sockets: &mut SocketSet<'a, 'b, 'c>,
rx_buffer: TcpSocketBuffer<'b>, rx_buffer: TcpSocketBuffer<'b>,
tx_buffer: TcpSocketBuffer<'b>, tx_buffer: TcpSocketBuffer<'b>,
rng: &'s mut dyn crate::TlsRng, rng: &'b mut dyn crate::TlsRng,
certificate_with_key: Option<( certificate_with_key: Option<(
crate::session::CertificatePrivateKey, crate::session::CertificatePrivateKey,
Vec<&'s [u8]> Vec<&'b [u8]>
)> )>
) -> Self ) -> Self
where where
@ -89,22 +89,22 @@ impl<'s> TlsSocket<'s> {
} }
} }
pub fn from_tcp_handle( // pub fn from_tcp_handle(
tcp_handle: SocketHandle, // tcp_handle: SocketHandle,
rng: &'s mut dyn crate::TlsRng, // rng: &'s mut dyn crate::TlsRng,
certificate_with_key: Option<( // certificate_with_key: Option<(
crate::session::CertificatePrivateKey, // crate::session::CertificatePrivateKey,
Vec<&'s [u8]> // Vec<&'s [u8]>
)> // )>
) -> Self { // ) -> Self {
TlsSocket { // TlsSocket {
tcp_handle, // tcp_handle,
rng, // rng,
session: RefCell::new( // session: RefCell::new(
Session::new(TlsRole::Client, certificate_with_key) // Session::new(TlsRole::Client, certificate_with_key)
), // ),
} // }
} // }
pub fn connect<T, U>( pub fn connect<T, U>(
&mut self, &mut self,