Skip to content

Commit 6f6fe80

Browse files
authored
Merge pull request #275 from epage/inner
feat(anstream): Provide read-only access to inner stream
2 parents 4735bcc + df887e2 commit 6f6fe80

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

crates/anstream/src/auto.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ where
157157
}
158158
}
159159

160+
/// Get the wrapped [`RawStream`]
161+
#[inline]
162+
pub fn as_inner(&self) -> &S {
163+
match &self.inner {
164+
StreamInner::PassThrough(w) => w,
165+
StreamInner::Strip(w) => w.as_inner(),
166+
#[cfg(all(windows, feature = "wincon"))]
167+
StreamInner::Wincon(w) => w.as_inner(),
168+
}
169+
}
170+
160171
/// Returns `true` if the descriptor/handle refers to a terminal/tty.
161172
#[inline]
162173
pub fn is_terminal(&self) -> bool {

crates/anstream/src/strip.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ where
3030
pub fn into_inner(self) -> S {
3131
self.raw
3232
}
33+
34+
/// Get the wrapped [`std::io::Write`]
35+
#[inline]
36+
pub fn as_inner(&self) -> &S {
37+
&self.raw
38+
}
3339
}
3440

3541
impl<S> StripStream<S>

crates/anstream/src/wincon.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ where
3434
pub fn into_inner(self) -> S {
3535
self.raw
3636
}
37+
38+
/// Get the wrapped [`std::io::Write`]
39+
#[inline]
40+
pub fn as_inner(&self) -> &S {
41+
&self.raw
42+
}
3743
}
3844

3945
impl<S> WinconStream<S>

0 commit comments

Comments
 (0)