We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd6f46a commit 45045ddCopy full SHA for 45045dd
libsql-wal/src/io/mod.rs
@@ -108,3 +108,33 @@ impl<T: Io> Io for Arc<T> {
108
self.as_ref().hard_link(src, dst)
109
}
110
111
+
112
+pub struct Inspect<W, F> {
113
+ inner: W,
114
+ f: F,
115
+}
116
117
+impl<W, F> Inspect<W, F> {
118
+ pub fn new(inner: W, f: F) -> Self {
119
+ Self { inner, f }
120
+ }
121
122
+ pub(crate) fn into_inner(self) -> W {
123
+ self.inner
124
125
126
127
+impl<W, F> io::Write for Inspect<W, F>
128
+where
129
+ W: io::Write,
130
+ for<'a> F: FnMut(&'a [u8]),
131
+ {
132
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
133
+ (self.f)(buf);
134
+ self.inner.write(buf)
135
136
137
+ fn flush(&mut self) -> io::Result<()> {
138
+ self.inner.flush()
139
140
0 commit comments