@@ -78,8 +78,18 @@ impl<W: Write> GzEncoder<W> {
7878
7979 /// Acquires a mutable reference to the underlying writer.
8080 ///
81- /// Note that mutation of the writer may result in surprising results if
82- /// this encoder is continued to be used.
81+ /// The underlying writer may be mutated or replaced as long as this
82+ /// preserves the bytes and ordering of the logical output stream.
83+ /// Concatenate output from each writer to reconstruct the complete stream.
84+ ///
85+ /// Replacing the writer does not require [`flush`](Write::flush). Call it
86+ /// first when all input accepted so far must be decodable without output
87+ /// from later writes. This inserts a sync-flush point and changes the output
88+ /// bitstream. This is useful before applying [`std::mem::take`] to
89+ /// [`get_mut`](Self::get_mut) when forwarding the stream incrementally.
90+ ///
91+ /// To start a new stream, call [`finish`](Self::finish) and create a new
92+ /// encoder; replacing the writer does not reset it.
8393 pub fn get_mut ( & mut self ) -> & mut W {
8494 self . inner . get_mut ( )
8595 }
@@ -254,8 +264,17 @@ impl<W: Write> GzDecoder<W> {
254264
255265 /// Acquires a mutable reference to the underlying writer.
256266 ///
257- /// Note that mutating the output/input state of the stream may corrupt this
258- /// object, so care must be taken when using this method.
267+ /// The underlying writer may be mutated or replaced as long as this
268+ /// preserves the bytes and ordering of the logical output stream.
269+ /// Concatenate output from each writer to reconstruct the complete stream.
270+ ///
271+ /// Replacing the writer does not require [`flush`](Write::flush). Call it
272+ /// first to write all decompressed output currently available to the
273+ /// current writer. This is useful before applying [`std::mem::take`] to
274+ /// [`get_mut`](Self::get_mut) when forwarding output incrementally.
275+ ///
276+ /// To start a new stream, call [`finish`](Self::finish) and create a new
277+ /// decoder; replacing the writer does not reset it.
259278 pub fn get_mut ( & mut self ) -> & mut W {
260279 self . inner . get_mut ( ) . get_mut ( )
261280 }
@@ -408,8 +427,17 @@ impl<W: Write> MultiGzDecoder<W> {
408427
409428 /// Acquires a mutable reference to the underlying writer.
410429 ///
411- /// Note that mutating the output/input state of the stream may corrupt this
412- /// object, so care must be taken when using this method.
430+ /// The underlying writer may be mutated or replaced as long as this
431+ /// preserves the bytes and ordering of the logical output stream.
432+ /// Concatenate output from each writer to reconstruct the complete stream.
433+ ///
434+ /// Replacing the writer does not require [`flush`](Write::flush). Call it
435+ /// first to write all decompressed output currently available to the
436+ /// current writer. This is useful before applying [`std::mem::take`] to
437+ /// [`get_mut`](Self::get_mut) when forwarding output incrementally.
438+ ///
439+ /// To start a new stream, call [`finish`](Self::finish) and create a new
440+ /// decoder; replacing the writer does not reset it.
413441 pub fn get_mut ( & mut self ) -> & mut W {
414442 self . inner . get_mut ( )
415443 }
0 commit comments