Lines Matching +full:write +full:- +full:output
9 /// This structure implements a [`Write`] interface and takes a stream of
12 /// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
19 /// use flate2::write::ZlibEncoder;
21 /// // Vec<u8> implements Write, assigning the compressed bytes of sample string
23 /// # fn zlib_encoding() -> std::io::Result<()> {
31 pub struct ZlibEncoder<W: Write> {
35 impl<W: Write> ZlibEncoder<W> {
36 /// Creates a new encoder which will write compressed data to the stream
41 pub fn new(w: W, level: crate::Compression) -> ZlibEncoder<W> { in new()
47 /// Creates a new encoder which will write compressed data to the stream
49 pub fn new_with_compress(w: W, compression: Compress) -> ZlibEncoder<W> { in new_with_compress()
56 pub fn get_ref(&self) -> &W { in get_ref()
62 /// Note that mutating the output/input state of the stream may corrupt this
64 pub fn get_mut(&mut self) -> &mut W { in get_mut()
68 /// Resets the state of this encoder entirely, swapping out the output
72 /// output stream before swapping out the two output streams.
75 /// state of this encoder and replace the output stream with the one
76 /// provided, returning the previous output stream. Future data written to
83 pub fn reset(&mut self, w: W) -> io::Result<W> { in reset()
89 /// Attempt to finish this output stream, writing out final chunks of data.
92 /// written to the output stream. After this function is called then further
93 /// calls to `write` may result in a panic.
97 /// Attempts to write data to this stream may result in a panic after this
104 pub fn try_finish(&mut self) -> io::Result<()> { in try_finish()
108 /// Consumes this encoder, flushing the output stream.
116 /// re-acquire ownership of a stream it is safe to call this method after
123 pub fn finish(mut self) -> io::Result<W> { in finish()
128 /// Consumes this encoder, flushing the output stream.
140 pub fn flush_finish(mut self) -> io::Result<W> { in flush_finish()
149 pub fn total_in(&self) -> u64 { in total_in()
157 pub fn total_out(&self) -> u64 { in total_out()
162 impl<W: Write> Write for ZlibEncoder<W> {
163 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write() method
164 self.inner.write(buf) in write()
167 fn flush(&mut self) -> io::Result<()> { in flush()
172 impl<W: Read + Write> Read for ZlibEncoder<W> {
173 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()
180 /// This structure implements a [`Write`] and will emit a stream of decompressed
183 /// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
191 /// # use flate2::write::ZlibEncoder;
192 /// use flate2::write::ZlibDecoder;
202 /// // Here Vec<u8> implements Write
204 /// fn decode_reader(bytes: Vec<u8>) -> io::Result<String> {
214 pub struct ZlibDecoder<W: Write> {
218 impl<W: Write> ZlibDecoder<W> {
219 /// Creates a new decoder which will write uncompressed data to the stream.
223 pub fn new(w: W) -> ZlibDecoder<W> { in new()
229 /// Creates a new decoder which will write uncompressed data to the stream `w`
234 pub fn new_with_decompress(w: W, decompression: Decompress) -> ZlibDecoder<W> { in new_with_decompress()
241 pub fn get_ref(&self) -> &W { in get_ref()
247 /// Note that mutating the output/input state of the stream may corrupt this
249 pub fn get_mut(&mut self) -> &mut W { in get_mut()
253 /// Resets the state of this decoder entirely, swapping out the output
257 /// output stream with the one provided, returning the previous output
259 /// the output stream `w`.
265 pub fn reset(&mut self, w: W) -> io::Result<W> { in reset()
271 /// Attempt to finish this output stream, writing out final chunks of data.
274 /// written to the output stream. After this function is called then further
275 /// calls to `write` may result in a panic.
279 /// Attempts to write data to this stream may result in a panic after this
286 pub fn try_finish(&mut self) -> io::Result<()> { in try_finish()
290 /// Consumes this encoder, flushing the output stream.
298 /// re-acquire ownership of a stream it is safe to call this method after
305 pub fn finish(mut self) -> io::Result<W> { in finish()
315 pub fn total_in(&self) -> u64 { in total_in()
320 /// output stream.
321 pub fn total_out(&self) -> u64 { in total_out()
326 impl<W: Write> Write for ZlibDecoder<W> {
327 fn write(&mut self, buf: &[u8]) -> io::Result<usize> { in write() method
328 self.inner.write(buf) in write()
331 fn flush(&mut self) -> io::Result<()> { in flush()
336 impl<W: Read + Write> Read for ZlibDecoder<W> {
337 fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { in read()