diff --git a/crates/anstream/src/auto.rs b/crates/anstream/src/auto.rs index 743640f8..16c995d0 100644 --- a/crates/anstream/src/auto.rs +++ b/crates/anstream/src/auto.rs @@ -157,6 +157,17 @@ where } } + /// Get the wrapped [`RawStream`] + #[inline] + pub fn as_inner(&self) -> &S { + match &self.inner { + StreamInner::PassThrough(w) => w, + StreamInner::Strip(w) => w.as_inner(), + #[cfg(all(windows, feature = "wincon"))] + StreamInner::Wincon(w) => w.as_inner(), + } + } + /// Returns `true` if the descriptor/handle refers to a terminal/tty. #[inline] pub fn is_terminal(&self) -> bool { diff --git a/crates/anstream/src/strip.rs b/crates/anstream/src/strip.rs index 9f0d28bd..47a0db0d 100644 --- a/crates/anstream/src/strip.rs +++ b/crates/anstream/src/strip.rs @@ -30,6 +30,12 @@ where pub fn into_inner(self) -> S { self.raw } + + /// Get the wrapped [`std::io::Write`] + #[inline] + pub fn as_inner(&self) -> &S { + &self.raw + } } impl StripStream diff --git a/crates/anstream/src/wincon.rs b/crates/anstream/src/wincon.rs index 570511dd..bb3fbdb8 100644 --- a/crates/anstream/src/wincon.rs +++ b/crates/anstream/src/wincon.rs @@ -34,6 +34,12 @@ where pub fn into_inner(self) -> S { self.raw } + + /// Get the wrapped [`std::io::Write`] + #[inline] + pub fn as_inner(&self) -> &S { + &self.raw + } } impl WinconStream