embedded_io_adapters/
fmt.rs1#[derive(Clone, Default, PartialEq, Debug)]
5pub struct ToFmt<T: ?Sized> {
6 inner: T,
7}
8
9impl<T> ToFmt<T> {
10 pub fn new(inner: T) -> Self {
12 Self { inner }
13 }
14
15 pub fn into_inner(self) -> T {
17 self.inner
18 }
19}
20
21impl<T: ?Sized> ToFmt<T> {
22 pub fn inner(&self) -> &T {
24 &self.inner
25 }
26
27 pub fn inner_mut(&mut self) -> &mut T {
29 &mut self.inner
30 }
31}
32
33impl<T: embedded_io::Write + ?Sized> core::fmt::Write for ToFmt<T> {
34 fn write_str(&mut self, s: &str) -> core::fmt::Result {
35 self.inner.write_all(s.as_bytes()).or(Err(core::fmt::Error))
36 }
37
38 }