Prepare for use of Write trait by renaming Write to WriteByte

This commit is contained in:
Jeremy Soller
2018-09-24 20:31:06 -06:00
parent 9eef8d7e2d
commit ef9fee5a2b
7 changed files with 23 additions and 25 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ use header::stdlib::mkstemp;
use header::string::strlen;
use platform;
use platform::types::*;
use platform::{c_str, errno, Read, Write};
use platform::{c_str, errno, ReadByte, WriteByte};
use platform::{Pal, Sys};
mod printf;
@@ -219,7 +219,7 @@ impl<'a> fmt::Write for LockGuard<'a> {
}
}
}
impl<'a> Write for LockGuard<'a> {
impl<'a> WriteByte for LockGuard<'a> {
fn write_u8(&mut self, byte: u8) -> fmt::Result {
if !self.0.can_write() {
return Err(Error);
@@ -231,7 +231,7 @@ impl<'a> Write for LockGuard<'a> {
}
}
}
impl<'a> Read for LockGuard<'a> {
impl<'a> ReadByte for LockGuard<'a> {
fn read_u8(&mut self) -> Result<Option<u8>, ()> {
let mut buf = [0];
match self.0.read(&mut buf) {
+2 -2
View File
@@ -2,10 +2,10 @@ use core::fmt::Write as CoreWrite;
use core::{ptr, slice, str};
use platform::types::*;
use platform::{self, Write};
use platform::{self, WriteByte};
use va_list::VaList;
pub unsafe fn printf<W: Write>(w: W, format: *const c_char, mut ap: VaList) -> c_int {
pub unsafe fn printf<W: WriteByte>(w: W, format: *const c_char, mut ap: VaList) -> c_int {
let mut w = platform::CountingWriter::new(w);
let format = slice::from_raw_parts(format as *const u8, usize::max_value());
+3 -3
View File
@@ -1,7 +1,7 @@
use alloc::String;
use alloc::Vec;
use platform::types::*;
use platform::Read;
use platform::ReadByte;
use va_list::VaList;
#[derive(PartialEq, Eq)]
@@ -27,7 +27,7 @@ unsafe fn next_byte(string: &mut *const c_char) -> Result<u8, c_int> {
}
}
unsafe fn inner_scanf<R: Read>(
unsafe fn inner_scanf<R: ReadByte>(
mut r: R,
mut format: *const c_char,
mut ap: VaList,
@@ -420,7 +420,7 @@ unsafe fn inner_scanf<R: Read>(
}
Ok(matched)
}
pub unsafe fn scanf<R: Read>(r: R, format: *const c_char, ap: VaList) -> c_int {
pub unsafe fn scanf<R: ReadByte>(r: R, format: *const c_char, ap: VaList) -> c_int {
match inner_scanf(r, format, ap) {
Ok(n) => n,
Err(n) => n,