Skip to content

Commit 79645fa

Browse files
committed
Add into_inner to encoder
1 parent 395ae9d commit 79645fa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/write/encoder.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,23 @@ impl<W: Write> EncoderWriter<W> {
215215
debug_assert_eq!(0, self.output_occupied_len);
216216
Ok(())
217217
}
218+
219+
/// Unwraps this `EncoderWriter`, returning the base writer it writes base64 encoded output
220+
/// to.
221+
///
222+
/// Normally this method should not be needed, since `finish()` returns the inner writer if
223+
/// it completes successfully. That will also ensure all data has been flushed, which the
224+
/// `into_inner()` function does *not* do.
225+
///
226+
/// Calling this method after `finish()` has completed successfully will panic, since the
227+
/// writer has already been returned.
228+
///
229+
/// This method may be useful if the writer implements additional APIs beyond the `Write`
230+
/// trait. Note that the inner writer might be in an error state or have an incomplete
231+
/// base64 string written to it.
232+
pub fn into_inner(mut self) -> W {
233+
self.delegate.take().unwrap()
234+
}
218235
}
219236

220237
impl<W: Write> Write for EncoderWriter<W> {

0 commit comments

Comments
 (0)