| 1 | //! The client end of a TLS connection. |
| 2 | |
| 3 | use craterust-analyzer cargo async-tls 0.13.0 crate/::commonrust-analyzer cargo async-tls 0.13.0 common/::tls_staterust-analyzer cargo async-tls 0.13.0 common/tls_state/::TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#; |
| 4 | use craterust-analyzer cargo async-tls 0.13.0 crate/::rusttlsrust-analyzer cargo async-tls 0.13.0 rusttls/::streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/::Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#; |
| 5 | use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!; |
| 6 | use futures_iorust-analyzer cargo futures-io 0.3.34 crate/::{AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead#, AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#}; |
| 7 | use rustlsrust-analyzer cargo rustls 0.23.43 crate/::ClientConnectionrust-analyzer cargo rustls 0.23.43 client/client_conn/connection/ClientConnection#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#; |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#; |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::{Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#}; |
| 11 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/, memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/}; |
| 12 | |
| 13 | /// The client end of a TLS connection. Can be used like any other bidirectional IO stream. |
| 14 | /// Wraps the underlying TCP stream. |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 16 | pub struct TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO> { |
| 17 | pub(craterust-analyzer cargo async-tls 0.13.0 crate/) iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io.: IO, |
| 18 | pub(craterust-analyzer cargo async-tls 0.13.0 crate/) sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.: ClientConnectionrust-analyzer cargo rustls 0.23.43 client/client_conn/connection/ClientConnection#, |
| 19 | pub(craterust-analyzer cargo async-tls 0.13.0 crate/) staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state.: TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#, |
| 20 | |
| 21 | #[cfg(feature = "early-data")] |
| 22 | pub(craterust-analyzer cargo async-tls 0.13.0 crate/) early_datarust-analyzer cargo async-tls 0.13.0 client/TlsStream#early_data.: (usize, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>), |
| 23 | } |
| 24 | |
| 25 | pub(craterust-analyzer cargo async-tls 0.13.0 crate/) enum MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#<IO> { |
| 26 | Handshakingrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#Handshaking#(TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO>), |
| 27 | #[cfg(feature = "early-data")] |
| 28 | EarlyDatarust-analyzer cargo async-tls 0.13.0 client/MidHandshake#EarlyData#(TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO>), |
| 29 | Endrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#End#, |
| 30 | } |
| 31 | |
| 32 | impl<IO> TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO> { |
| 33 | /// Returns a reference to the underlying IO stream. |
| 34 | pub fn get_refrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`]get_ref().(&self) -> &IO { |
| 35 | &self.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io. |
| 36 | } |
| 37 | |
| 38 | /// Returns a mutuable reference to the underlying IO stream. |
| 39 | pub fn get_mutrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`]get_mut().(&mut self) -> &mut IO { |
| 40 | &mut self.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io. |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | impl<IO> Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#<IO> |
| 45 | where |
| 46 | IO: AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# + AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 47 | { |
| 48 | type Outputrust-analyzer cargo async-tls 0.13.0 client/impl#[`MidHandshake<IO>`][Future]Output# = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO>>; |
| 49 | |
| 50 | #[inline] |
| 51 | fn pollrust-analyzer cargo async-tls 0.13.0 client/impl#[`MidHandshake<IO>`][Future]poll().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`MidHandshake<IO>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`MidHandshake<IO>`][Future]::Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#Output#> { |
| 52 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 53 | |
| 54 | if let MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#::Handshakingrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#Handshaking#(stream) = this { |
| 55 | let eof = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stream.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().(); |
| 56 | let (io, session) = (&mut stream.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut stream.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.); |
| 57 | let mut stream = Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(io, session).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(eof); |
| 58 | |
| 59 | if stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..is_handshakingrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]is_handshaking().() { |
| 60 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.complete_iorust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]complete_io().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 61 | } |
| 62 | |
| 63 | if stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..wants_writerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]wants_write().() { |
| 64 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.complete_iorust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]complete_io().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | match memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(this, MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#::Endrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#End#) { |
| 69 | MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#::Handshakingrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#Handshaking#(stream) => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(stream)), |
| 70 | #[cfg(feature = "early-data")] |
| 71 | MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#::EarlyDatarust-analyzer cargo async-tls 0.13.0 client/MidHandshake#EarlyData#(stream) => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(stream)), |
| 72 | MidHandshakerust-analyzer cargo async-tls 0.13.0 client/MidHandshake#::Endrust-analyzer cargo async-tls 0.13.0 client/MidHandshake#End# => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(), |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | impl<IO> AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# for TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO> |
| 78 | where |
| 79 | IO: AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# + AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 80 | { |
| 81 | fn poll_readrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncRead]poll_read().( |
| 82 | self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncRead]>, |
| 83 | cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 84 | buf: &mut [u8], |
| 85 | ) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 86 | match self.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state. { |
| 87 | #[cfg(feature = "early-data")] |
| 88 | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::EarlyDatarust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#EarlyData# => { |
| 89 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 90 | |
| 91 | let is_handshaking = this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session..is_handshakingrust-analyzer cargo rustls 0.23.43 common_state/impl#[CommonState]is_handshaking().(); |
| 92 | let is_early_data_accepted = this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session..is_early_data_acceptedrust-analyzer cargo rustls 0.23.43 client/client_conn/connection/impl#[ClientConnection]is_early_data_accepted().(); |
| 93 | |
| 94 | let mut stream = |
| 95 | Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(&mut this.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().()); |
| 96 | let (pos, data) = &mut this.early_datarust-analyzer cargo async-tls 0.13.0 client/TlsStream#early_data.; |
| 97 | |
| 98 | // complete handshake |
| 99 | if is_handshaking { |
| 100 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.complete_iorust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]complete_io().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 101 | } |
| 102 | |
| 103 | // write early data (fallback) |
| 104 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_early_data_accepted { |
| 105 | while *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 106 | let len = readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_writerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_write().(cx, &data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 107 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().len; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // end |
| 112 | this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state. = TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::Streamrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#Stream#; |
| 113 | data.clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 114 | |
| 115 | Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]new().(this).poll_readrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncRead]poll_read().(cx, buf) |
| 116 | } |
| 117 | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::Streamrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#Stream# | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::WriteShutdownrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#WriteShutdown# => { |
| 118 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 119 | let mut stream = |
| 120 | Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(&mut this.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().()); |
| 121 | |
| 122 | match stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_readrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncRead]poll_read().(cx, buf) { |
| 123 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)) => { |
| 124 | this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..shutdown_readrust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]shutdown_read().(); |
| 125 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)) |
| 126 | } |
| 127 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n)) => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n)), |
| 128 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ref e)) if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::ConnectionAbortedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#ConnectionAborted# => { |
| 129 | this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..shutdown_readrust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]shutdown_read().(); |
| 130 | if this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..writeablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]writeable().() { |
| 131 | stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..send_close_notifyrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]send_close_notify().(); |
| 132 | this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..shutdown_writerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]shutdown_write().(); |
| 133 | } |
| 134 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)) |
| 135 | } |
| 136 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)) => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)), |
| 137 | Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending#, |
| 138 | } |
| 139 | } |
| 140 | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::ReadShutdownrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#ReadShutdown# | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::FullyShutdownrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#FullyShutdown# => Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)), |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | impl<IO> AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite# for TlsStreamrust-analyzer cargo async-tls 0.13.0 client/TlsStream#<IO> |
| 146 | where |
| 147 | IO: AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# + AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 148 | { |
| 149 | fn poll_writerust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]poll_write().( |
| 150 | self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]>, |
| 151 | cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 152 | buf: &[u8], |
| 153 | ) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 154 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 155 | let mut stream = |
| 156 | Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(&mut this.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().()); |
| 157 | |
| 158 | match this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state. { |
| 159 | #[cfg(feature = "early-data")] |
| 160 | TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::EarlyDatarust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#EarlyData# => { |
| 161 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 162 | |
| 163 | let (pos, data) = &mut this.early_datarust-analyzer cargo async-tls 0.13.0 client/TlsStream#early_data.; |
| 164 | |
| 165 | // write early data |
| 166 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut early_data) = stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..client_early_datarust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]client_early_data().() { |
| 167 | let len = match early_data.writerust-analyzer cargo rustls 0.23.43 client/client_conn/connection/impl#[`WriteEarlyData<'_>`][Write]write().(buf) { |
| 168 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(n) => n, |
| 169 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ref err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => { |
| 170 | return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 171 | } |
| 172 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)), |
| 173 | }; |
| 174 | data.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 175 | return Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len)); |
| 176 | } |
| 177 | |
| 178 | // complete handshake |
| 179 | if stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..is_handshakingrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]is_handshaking().() { |
| 180 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.complete_iorust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]complete_io().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 181 | } |
| 182 | |
| 183 | // write early data (fallback) |
| 184 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stream.connrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#conn..is_early_data_acceptedrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Conn<'_>`]is_early_data_accepted().() { |
| 185 | while *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 186 | let len = readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_writerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_write().(cx, &data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 187 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().len; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // end |
| 192 | this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state. = TlsStaterust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#::Streamrust-analyzer cargo async-tls 0.13.0 common/tls_state/TlsState#Stream#; |
| 193 | data.clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().(); |
| 194 | stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_writerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_write().(cx, buf) |
| 195 | } |
| 196 | _ => stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_writerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_write().(cx, buf), |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | fn poll_flushrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]poll_flush().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 201 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 202 | let mut stream = |
| 203 | Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(&mut this.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().()); |
| 204 | stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_flushrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_flush().(cx) |
| 205 | } |
| 206 | |
| 207 | fn poll_closerust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]poll_close().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo async-tls 0.13.0 client/impl#[`TlsStream<IO>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 208 | if self.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..writeablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]writeable().() { |
| 209 | self.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session..send_close_notifyrust-analyzer cargo rustls 0.23.43 common_state/impl#[CommonState]send_close_notify().(); |
| 210 | self.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..shutdown_writerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]shutdown_write().(); |
| 211 | } |
| 212 | |
| 213 | let this = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<&'a mut T>`]get_mut().(); |
| 214 | let mut stream = |
| 215 | Streamrust-analyzer cargo async-tls 0.13.0 rusttls/stream/Stream#::newrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]new().(&mut this.iorust-analyzer cargo async-tls 0.13.0 client/TlsStream#io., &mut this.sessionrust-analyzer cargo async-tls 0.13.0 client/TlsStream#session.).set_eofrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]set_eof().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.staterust-analyzer cargo async-tls 0.13.0 client/TlsStream#state..readablerust-analyzer cargo async-tls 0.13.0 common/tls_state/impl#[TlsState]readable().()); |
| 216 | stream.as_mut_pinrust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`]as_mut_pin().().poll_closerust-analyzer cargo async-tls 0.13.0 rusttls/stream/impl#[`Stream<'a, IO>`][AsyncWrite]poll_close().(cx) |
| 217 | } |
| 218 | } |