Skip to content

Commit acbe139

Browse files
197gHomu
authored andcommitted
Implement accessors for the Tracer
This makes the `Tracer` wrapper for a phy device close to a drop-in replacement for the encapsulated device. Closes: #289 Approved by: whitequark
1 parent 599afcc commit acbe139

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/phy/tracer.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ impl<D: for<'a> Device<'a>, P: PrettyPrint> Tracer<D, P> {
1919
Tracer { inner, writer }
2020
}
2121

22+
/// Get a reference to the underlying device.
23+
///
24+
/// Even if the device offers reading through a standard reference, it is inadvisable to
25+
/// directly read from the device as doing so will circumvent the tracing.
26+
pub fn get_ref(&self) -> &D {
27+
&self.inner
28+
}
29+
30+
/// Get a mutable reference to the underlying device.
31+
///
32+
/// It is inadvisable to directly read from the device as doing so will circumvent the tracing.
33+
pub fn get_mut(&mut self) -> &mut D {
34+
&mut self.inner
35+
}
36+
2237
/// Return the underlying device, consuming the tracer.
2338
pub fn into_inner(self) -> D {
2439
self.inner

0 commit comments

Comments
 (0)