playdate_device/serial/
blocking.rs1use std::io::prelude::*;
2
3use crate::error::Error;
4use super::Interface;
5
6
7impl crate::interface::blocking::Out for Interface {
8 #[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
9 fn send_cmd(&self, cmd: crate::device::command::Command) -> Result<usize, Error> {
10 trace!("sending `{cmd}` to {}", self.info.port_name);
11 if let Some(ref port) = self.port {
12 let s = cmd.with_break();
13 let mut port = port.try_borrow_mut()?;
14 port.write_all(s.as_bytes())?;
15 port.flush()?;
16 Ok(s.as_bytes().len())
17 } else {
18 Err(Error::not_ready())
19 }
20 }
21}
22
23impl crate::interface::blocking::In for Interface {}