cortex_m_log/destination/
semihosting.rs

1//! Semihosting module
2
3extern crate cortex_m_semihosting as sh;
4
5use core::fmt;
6use core::fmt::Write;
7
8/// Trait implemented for writes that can be used with [SH](struct.SH.html)
9pub trait SemihostingComp: Write {}
10
11impl SemihostingComp for sh::hio::HostStream {}
12
13/// Semihosting destination
14pub struct SH<T: SemihostingComp> {
15    inner: T,
16}
17
18impl<T: SemihostingComp> SH<T> {
19    #[inline]
20    ///Creates new instance
21    pub fn new(inner: T) -> SH<T> {
22        Self {
23            inner
24        }
25    }
26}
27
28impl<T: SemihostingComp> Write for SH<T> {
29    #[inline]
30    fn write_str(&mut self, s: &str) -> fmt::Result {
31        self.inner.write_str(s)
32    }
33}
34
35/// Alias to semihosting's stdout
36pub type SHStream = SH<sh::hio::HostStream>;