From c0df9a3b95b50a5b9d08368a296e6d70e5f515f2 Mon Sep 17 00:00:00 2001 From: Matt Harvey Date: Tue, 14 Sep 2021 16:04:34 -0700 Subject: [PATCH] kata-io alias analogous to io::Result Sometimes it is useful for kata-io to be API-compatible with std::io (e.g. porting a ZMODEM library). std::io has a similarly defined alias where E is its own error type. Change-Id: Idaf88fb1d41bcb984608d82a0ea222290c78f5c4 GitOrigin-RevId: 5738e6ac705b6fe3b48dd64891808cf50b75afb7 --- apps/system/components/DebugConsole/kata-io/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/system/components/DebugConsole/kata-io/src/lib.rs b/apps/system/components/DebugConsole/kata-io/src/lib.rs index 5eb7877..9ca92d3 100644 --- a/apps/system/components/DebugConsole/kata-io/src/lib.rs +++ b/apps/system/components/DebugConsole/kata-io/src/lib.rs @@ -2,14 +2,16 @@ pub struct Error; +pub type Result = core::result::Result; + /// Interface for the CLI to consume bytes. pub trait Read { - fn read(&mut self, buf: &mut [u8]) -> Result; + fn read(&mut self, buf: &mut [u8]) -> Result; } /// Interface for the CLI to emit bytes. pub trait Write { - fn write(&mut self, buf: &[u8]) -> Result; + fn write(&mut self, buf: &[u8]) -> Result; } /// Adapter for writing core::fmt formatted strings. @@ -24,7 +26,7 @@ impl core::fmt::Write for dyn Write + '_ { } impl dyn Read + '_ { - pub fn get_u8(&mut self) -> Result { + pub fn get_u8(&mut self) -> Result { let mut buf: [u8; 1] = [0u8]; let n_read = self.read(&mut buf)?; match n_read {