diff --git a/Cargo.toml b/Cargo.toml index 45b80b1..ee6274e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,6 @@ repository = "https://github.com/fluffysquirrels/framed" cobs = "^0.1.3" ref_slice = "^1.1.1" -[dependencies.core-io] -git = "https://github.com/QuiltOS/core-io" -rev = "f084f913011c9916d420b520ead3953a2ccb950e" - [features] default = ["use_std"] diff --git a/src/error.rs b/src/error.rs index 0b5f144..8649a87 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,7 +10,7 @@ use core::result; pub type Result = result::Result; -#[cfg_attr(feature = "use_std", derive(Debug))] +#[derive(Debug)] pub enum Error { /// COBS decode failed CobsDecodeFailed, @@ -21,12 +21,6 @@ pub enum Error { /// Forwarded io::Error. #[cfg(feature = "use_std")] Io(io::Error), - - /// Forwarded Io error. - /// - /// TODO: Store some extra value here. - #[cfg(not(feature = "use_std"))] - Io, } #[cfg(feature = "use_std")] diff --git a/src/lib.rs b/src/lib.rs index 9ce5ff5..160451f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,6 @@ #![cfg_attr(not(feature = "use_std"), no_std)] extern crate cobs; -#[cfg(not(feature = "use_std"))] -extern crate core_io; extern crate ref_slice; @@ -42,16 +40,15 @@ use ref_slice::ref_slice_mut; #[cfg(feature = "use_std")] use std::io::{self, Read, Write}; -#[cfg(not(feature = "use_std"))] -use core_io::{Read, Write}; - const FRAME_END: u8 = 0; /// Sends frames over an underlying `io::Write` instance. +#[cfg(feature = "use_std")] pub struct Sender { w: W, } +#[cfg(feature = "use_std")] impl Sender { pub fn new(w: W) -> Sender { Sender:: { @@ -70,11 +67,6 @@ impl Sender { self.w.write(&code)?; } - #[cfg(not(feature = "use_std"))] { - self.w.write(&code) - .map_err(|_| Error::Io)?; - } - Ok(()) } } @@ -83,6 +75,7 @@ impl Sender { /// /// TODO: Add a recv() variant suitable for no_std use, e.g. one that /// takes a `&mut [u8]`. +#[cfg(feature = "use_std")] pub struct Receiver { #[cfg_attr(not(feature = "use_std"), allow(dead_code))] @@ -90,6 +83,7 @@ pub struct Receiver { r: R, } +#[cfg(feature = "use_std")] impl Receiver { pub fn new(r: R) -> Receiver { Receiver:: { @@ -97,7 +91,6 @@ impl Receiver { } } - #[cfg(feature = "use_std")] pub fn recv(&mut self) -> Result> { let mut next_frame = Vec::new(); @@ -132,7 +125,7 @@ impl Receiver { } } -#[cfg(test)] +#[cfg(all(test, not(feature = "use_std")))] mod tests { use channel::Channel; use error::Error;