You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
serial: add methods to retrieve the underlying output writer
Add three methods (writer(), writer_mut() and into_writer()) to Serial
in order to obtain the original output object back from the device.
This allows the device to gain ownership of the object and for the
caller to retrieve it back when needed.
Otherwise, if one wants the device to write output into an in-memory
structure (e.g. a Vec), which can later be accessed, one must give
out a mutable reference. This can be problematic if one stores the
buffer and the device within the same structure due to Rust's issues
with self-referential structures. This is also more ergonomic in
terms of saving and restoring the device's state, if one considers
the output part of the state.
Signed-off-by: Carlos López <[email protected]>
0 commit comments