ufmt_stdio/imp/
std_c.rs

1///Stdout wrapper
2pub struct Stdout {
3}
4
5impl Stdout {
6    ///Creates new instance;
7    pub const fn new() -> Self {
8        Self {
9        }
10    }
11}
12
13///Stderr wrapper
14pub struct Stderr {
15}
16
17impl Stderr {
18    ///Creates new instance;
19    pub const fn new() -> Self {
20        Self {
21        }
22    }
23}
24
25impl ufmt::uWrite for Stdout {
26    type Error = ();
27
28    fn write_str(&mut self, text: &str) -> Result<(), Self::Error> {
29        let result = unsafe {
30            libc::write(1, text.as_ptr() as *const _, text.len() as _)
31        };
32
33        if result < 0 {
34            Err(())
35        } else {
36            Ok(())
37        }
38    }
39}
40
41impl ufmt::uWrite for Stderr {
42    type Error = ();
43
44    fn write_str(&mut self, text: &str) -> Result<(), Self::Error> {
45        let result = unsafe {
46            libc::write(2, text.as_ptr() as *const _, text.len() as _)
47        };
48
49        if result < 0 {
50            Err(())
51        } else {
52            Ok(())
53        }
54    }
55}