| 1 | use superrust-analyzer cargo futures_codec 0.4.1 crate/::fuserust-analyzer cargo futures_codec 0.4.1 fuse/::Fuserust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#; |
| 2 | use superrust-analyzer cargo futures_codec 0.4.1 crate/::Encoderrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#; |
| 3 | use bytesrust-analyzer cargo bytes 1.12.1 crate/::{Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#, BytesMutrust-analyzer cargo bytes 1.12.1 bytes_mut/BytesMut#}; |
| 4 | use futuresrust-analyzer cargo futures 0.3.34 crate/::iorust-analyzer cargo futures-util 0.3.34 io/::{AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead#, AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#}; |
| 5 | use futuresrust-analyzer cargo futures 0.3.34 crate/::{readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!, Sinkrust-analyzer cargo futures-sink 0.3.34 Sink#}; |
| 6 | use pin_projectrust-analyzer cargo pin-project 1.1.13 crate/::pin_projectrust-analyzer cargo pin-project-internal 1.1.13 pin_project:; |
| 7 | 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/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#}; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#; |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#}; |
| 10 | 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#; |
| 11 | 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#}; |
| 12 | |
| 13 | /// A `Sink` of frames encoded to an `AsyncWrite`. |
| 14 | /// |
| 15 | /// # Example |
| 16 | /// ``` |
| 17 | /// use bytes::Bytes; |
| 18 | /// use futures_codec::{FramedWrite, BytesCodec}; |
| 19 | /// use futures::SinkExt; |
| 20 | /// |
| 21 | /// # futures::executor::block_on(async move { |
| 22 | /// let mut buf = Vec::new(); |
| 23 | /// let mut framed = FramedWrite::new(&mut buf, BytesCodec {}); |
| 24 | /// |
| 25 | /// let bytes = Bytes::from("Hello World!"); |
| 26 | /// framed.send(bytes.clone()).await?; |
| 27 | /// |
| 28 | /// assert_eq!(&buf[..], &bytes[..]); |
| 29 | /// # Ok::<_, std::io::Error>(()) |
| 30 | /// # }).unwrap(); |
| 31 | /// ``` |
| 32 | #[pin_projectrust-analyzer cargo pin-project-internal 1.1.13 pin_project:] |
| 33 | #[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:)] |
| 34 | pub struct FramedWriterust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#<T, E> { |
| 35 | #[pinrust-analyzer cargo pin-project-internal 1.1.13 pin:] |
| 36 | innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner.: FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<Fuserust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#<T, E>>, |
| 37 | } |
| 38 | |
| 39 | impl<T, E> FramedWriterust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#<T, E> |
| 40 | where |
| 41 | T: AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#, |
| 42 | E: Encoderrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#, |
| 43 | { |
| 44 | /// Creates a new `FramedWrite` transport with the given `Encoder`. |
| 45 | pub fn newrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]new().(inner: T, encoder: E) -> Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`] { |
| 46 | Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`] { |
| 47 | innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner.: framed_write_2rust-analyzer cargo futures_codec 0.4.1 framed_write/framed_write_2().(Fuserust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#::newrust-analyzer cargo futures_codec 0.4.1 fuse/impl#[`Fuse<T, U>`]new().(inner, encoder)), |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /// High-water mark for writes, in bytes |
| 52 | /// |
| 53 | /// The send *high-water mark* prevents the `FramedWrite` |
| 54 | /// from accepting additional messages to send when its |
| 55 | /// buffer exceeds this length, in bytes. Attempts to enqueue |
| 56 | /// additional messages will be deferred until progress is |
| 57 | /// made on the underlying `AsyncWrite`. This applies |
| 58 | /// back-pressure on fast senders and prevents unbounded |
| 59 | /// buffer growth. |
| 60 | /// |
| 61 | /// See [`set_send_high_water_mark()`](#method.set_send_high_water_mark). |
| 62 | pub fn send_high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]send_high_water_mark().(&self) -> usize { |
| 63 | return self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner..high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#high_water_mark.; |
| 64 | } |
| 65 | |
| 66 | /// Sets high-water mark for writes, in bytes |
| 67 | /// |
| 68 | /// The send *high-water mark* prevents the `FramedWrite` |
| 69 | /// from accepting additional messages to send when its |
| 70 | /// buffer exceeds this length, in bytes. Attempts to enqueue |
| 71 | /// additional messages will be deferred until progress is |
| 72 | /// made on the underlying `AsyncWrite`. This applies |
| 73 | /// back-pressure on fast senders and prevents unbounded |
| 74 | /// buffer growth. |
| 75 | /// |
| 76 | /// The default high-water mark is 2^17 bytes. Applications |
| 77 | /// which desire low latency may wish to reduce this value. |
| 78 | /// There is little point to increasing this value beyond |
| 79 | /// your socket's `SO_SNDBUF` size. On linux, this defaults |
| 80 | /// to 212992 bytes but is user-adjustable. |
| 81 | pub fn set_send_high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]set_send_high_water_mark().(&mut self, hwm: usize) { |
| 82 | self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner..high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#high_water_mark. = hwm; |
| 83 | } |
| 84 | |
| 85 | /// Release the I/O and Encoder |
| 86 | pub fn releaserust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]release().(self) -> (T, E) { |
| 87 | let fuse = self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner..releaserust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`]release().(); |
| 88 | (fuse.trust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#t., fuse.urust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#u.) |
| 89 | } |
| 90 | |
| 91 | /// Consumes the `FramedWrite`, returning its underlying I/O stream. |
| 92 | /// |
| 93 | /// Note that care should be taken to not tamper with the underlying stream |
| 94 | /// of data coming in as it may corrupt the stream of frames otherwise |
| 95 | /// being worked with. |
| 96 | pub fn into_innerrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]into_inner().(self) -> T { |
| 97 | self.releaserust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]release().().0 |
| 98 | } |
| 99 | |
| 100 | /// Returns a reference to the underlying encoder. |
| 101 | /// |
| 102 | /// Note that care should be taken to not tamper with the underlying encoder |
| 103 | /// as it may corrupt the stream of frames otherwise being worked with. |
| 104 | pub fn encoderrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]encoder().(&self) -> &E { |
| 105 | &self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner..urust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#u. |
| 106 | } |
| 107 | |
| 108 | /// Returns a mutable reference to the underlying encoder. |
| 109 | /// |
| 110 | /// Note that care should be taken to not tamper with the underlying encoder |
| 111 | /// as it may corrupt the stream of frames otherwise being worked with. |
| 112 | pub fn encoder_mutrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]encoder_mut().(&mut self) -> &mut E { |
| 113 | &mut self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner..urust-analyzer cargo futures_codec 0.4.1 fuse/Fuse#u. |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | impl<T, E> Sinkrust-analyzer cargo futures-sink 0.3.34 Sink#<E::Itemrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Item#> for FramedWriterust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#<T, E> |
| 118 | where |
| 119 | T: 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#, |
| 120 | E: Encoderrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#, |
| 121 | { |
| 122 | type Errorrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]Error# = E::Errorrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Error#; |
| 123 | |
| 124 | fn poll_readyrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]poll_ready().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 125 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWriteProjection#inner..poll_readyrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_ready().(cx) |
| 126 | } |
| 127 | fn start_sendrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]start_send().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]>, item: E::Itemrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Item#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#> { |
| 128 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWriteProjection#inner..start_sendrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]start_send().(item) |
| 129 | } |
| 130 | fn poll_flushrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]poll_flush().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 131 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWriteProjection#inner..poll_flushrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_flush().(cx) |
| 132 | } |
| 133 | fn poll_closerust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]poll_close().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][`Sink<<E as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 134 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWriteProjection#inner..poll_closerust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_close().(cx) |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | impl<T, E> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for FramedWriterust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#<T, E> { |
| 139 | type Targetrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][Deref]Target# = T; |
| 140 | |
| 141 | fn derefrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][Deref]deref().(&self) -> &T { |
| 142 | &self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner. |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | impl<T, E> DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for FramedWriterust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#<T, E> { |
| 147 | fn deref_mutrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite<T, E>`][DerefMut]deref_mut().(&mut self) -> &mut T { |
| 148 | &mut self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite#inner. |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | #[pin_projectrust-analyzer cargo pin-project-internal 1.1.13 pin_project:] |
| 153 | #[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:)] |
| 154 | pub struct FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 155 | #[pinrust-analyzer cargo pin-project-internal 1.1.13 pin:] |
| 156 | pub innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner.: T, |
| 157 | pub high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#high_water_mark.: usize, |
| 158 | bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer.: BytesMutrust-analyzer cargo bytes 1.12.1 bytes_mut/BytesMut#, |
| 159 | } |
| 160 | |
| 161 | impl<T> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 162 | type Targetrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][Deref]Target# = T; |
| 163 | |
| 164 | fn derefrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][Deref]deref().(&self) -> &T { |
| 165 | &self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner. |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | impl<T> DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 170 | fn deref_mutrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][DerefMut]deref_mut().(&mut self) -> &mut T { |
| 171 | &mut self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner. |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // 2^17 bytes, which is slightly over 60% of the default |
| 176 | // TCP send buffer size (SO_SNDBUF) |
| 177 | const DEFAULT_SEND_HIGH_WATER_MARKrust-analyzer cargo futures_codec 0.4.1 framed_write/DEFAULT_SEND_HIGH_WATER_MARK.: usize = 131072; |
| 178 | |
| 179 | pub fn framed_write_2rust-analyzer cargo futures_codec 0.4.1 framed_write/framed_write_2().<T>(inner: T) -> FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 180 | FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2# { |
| 181 | innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner., |
| 182 | high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#high_water_mark.: DEFAULT_SEND_HIGH_WATER_MARKrust-analyzer cargo futures_codec 0.4.1 framed_write/DEFAULT_SEND_HIGH_WATER_MARK., |
| 183 | bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer.: BytesMutrust-analyzer cargo bytes 1.12.1 bytes_mut/BytesMut#::with_capacityrust-analyzer cargo bytes 1.12.1 bytes_mut/impl#[BytesMut]with_capacity().(1028 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().8), |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | impl<T: AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#> AsyncReadrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead# for FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 188 | fn poll_readrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][AsyncRead]poll_read().( |
| 189 | self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][AsyncRead]>, |
| 190 | cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 191 | buf: &mut [u8], |
| 192 | ) -> Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#>> { |
| 193 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#inner..poll_readrust-analyzer cargo futures-io 0.3.34 if_std/AsyncRead#poll_read().(cx, buf) |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | impl<T> Sinkrust-analyzer cargo futures-sink 0.3.34 Sink#<T::Itemrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Item#> for FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> |
| 198 | where |
| 199 | T: AsyncWriterust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite# + Encoderrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 200 | { |
| 201 | type Errorrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]Error# = T::Errorrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Error#; |
| 202 | |
| 203 | fn poll_readyrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_ready().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 204 | let this = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self; |
| 205 | while this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer..lenrust-analyzer cargo bytes 1.12.1 bytes_mut/impl#[BytesMut]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().this.high_water_markrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#high_water_mark. { |
| 206 | let num_write = readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(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().(&mut this.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner.).poll_writerust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#poll_write().(cx, &this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 207 | |
| 208 | if num_write rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 209 | 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_eofrust-analyzer cargo futures_codec 0.4.1 framed_write/err_eof().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 210 | } |
| 211 | |
| 212 | this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer..advancerust-analyzer cargo bytes 1.12.1 bytes_mut/impl#[BytesMut][Buf]advance().(num_write); |
| 213 | } |
| 214 | |
| 215 | 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#(())) |
| 216 | } |
| 217 | fn start_sendrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]start_send().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]>, item: T::Itemrust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#Item#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#> { |
| 218 | let this = &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self; |
| 219 | this.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner..encoderust-analyzer cargo futures_codec 0.4.1 encoder/Encoder#encode().(item, &mut this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#buffer.) |
| 220 | } |
| 221 | fn poll_flushrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_flush().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 222 | let mut this = self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`]project().(); |
| 223 | |
| 224 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#buffer..is_emptyrust-analyzer cargo bytes 1.12.1 bytes_mut/impl#[BytesMut]is_empty().() { |
| 225 | let num_write = readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(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().(&mut this.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#inner.).poll_writerust-analyzer cargo futures-io 0.3.34 if_std/impl#[`Pin<P>`][AsyncWrite]poll_write().(cx, &this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#buffer.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 226 | |
| 227 | if num_write rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 228 | 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_eofrust-analyzer cargo futures_codec 0.4.1 framed_write/err_eof().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 229 | } |
| 230 | |
| 231 | this.bufferrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#buffer..advancerust-analyzer cargo bytes 1.12.1 bytes_mut/impl#[BytesMut][Buf]advance().(num_write); |
| 232 | } |
| 233 | |
| 234 | this.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#inner..poll_flushrust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#poll_flush().(cx).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<Result<T, E>>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 235 | } |
| 236 | fn poll_closerust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_close().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]>, 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#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Selfrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]::Errorrust-analyzer cargo futures-sink 0.3.34 Sink#Error#>> { |
| 237 | readyrust-analyzer cargo futures-core 0.3.34 task/poll/ready!!(self.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().poll_flushrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`][`Sink<<T as Encoder>::Item>`]poll_flush().(cx))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 238 | self.projectrust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`]project().().innerrust-analyzer cargo futures_codec 0.4.1 framed_write/__FramedWrite2Projection#inner..poll_closerust-analyzer cargo futures-io 0.3.34 if_std/AsyncWrite#poll_close().(cx).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/impl#[`Poll<Result<T, E>>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | impl<T> FramedWrite2rust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#<T> { |
| 243 | pub fn releaserust-analyzer cargo futures_codec 0.4.1 framed_write/impl#[`FramedWrite2<T>`]release().(self) -> T { |
| 244 | self.innerrust-analyzer cargo futures_codec 0.4.1 framed_write/FramedWrite2#inner. |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | fn err_eofrust-analyzer cargo futures_codec 0.4.1 framed_write/err_eof().() -> Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error# { |
| 249 | Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof#, "End of file") |
| 250 | } |