From 26bde04a1948a16a693a039748f30b8b04573b5a Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 5 Aug 2024 13:20:16 +0800 Subject: [PATCH] core_io -> core2::io --- libconfig/Cargo.toml | 6 ++---- libconfig/src/bootgen.rs | 2 +- libconfig/src/lib.rs | 18 ++++++++++-------- libconfig/src/sd_reader.rs | 2 +- szl/Cargo.toml | 6 +++--- szl/src/main.rs | 2 +- szl/src/netboot.rs | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libconfig/Cargo.toml b/libconfig/Cargo.toml index ab509ba..e1c7fa8 100644 --- a/libconfig/Cargo.toml +++ b/libconfig/Cargo.toml @@ -6,9 +6,8 @@ edition = "2021" [dependencies] libboard_zynq = { path = "../libboard_zynq" } -<<<<<<< HEAD -core_io = { version = "0.1", features = ["collections"] } -fatfs = { version = "0.3", features = ["core_io"], default-features = false } +core2 = { version = "=0.3.2", features = ["alloc", "nightly"], default-features = false } +fatfs = { git = "https://github.com/SimonRenblad/rust-fatfs", branch = "stable-0.3", features = ["core2", "alloc"], default-features = false } log = "=0.4.14" [features] @@ -17,4 +16,3 @@ target_coraz7 = [] target_redpitaya = [] target_kasli_soc = [] ipv6 = [] -fat_lfn = [ "fatfs/alloc" ] diff --git a/libconfig/src/bootgen.rs b/libconfig/src/bootgen.rs index 884f22c..cb60716 100644 --- a/libconfig/src/bootgen.rs +++ b/libconfig/src/bootgen.rs @@ -1,5 +1,5 @@ use alloc::vec::Vec; -use core_io::{Error, Read, Seek, SeekFrom}; +use core2::io::{Error, Read, Seek, SeekFrom}; use libboard_zynq::devc; use log::debug; diff --git a/libconfig/src/lib.rs b/libconfig/src/lib.rs index f1bf1b1..3cdf4cf 100644 --- a/libconfig/src/lib.rs +++ b/libconfig/src/lib.rs @@ -3,7 +3,7 @@ extern crate alloc; use core::fmt; use alloc::{string::FromUtf8Error, string::String, vec::Vec, rc::Rc}; -use core_io::{self as io, BufRead, BufReader, Read, Write, Seek, SeekFrom}; +use core2::io::{self as io, Read, Write, Seek, SeekFrom}; use libboard_zynq::sdio; pub mod sd_reader; @@ -54,11 +54,13 @@ impl<'a> From for Error<'a> { fn parse_config<'a>( key: &'a str, buffer: &mut Vec, - file: fatfs::File, + file: &mut fatfs::File, ) -> Result<'a, ()> { let prefix = [key, "="].concat().to_ascii_lowercase(); - for line in BufReader::new(file).lines() { - let line = line?.to_ascii_lowercase(); + let mut read_buf = Vec::new(); + file.read_to_end(&mut read_buf)?; + for line in String::from_utf8(read_buf)?.lines() { + let line = line.to_ascii_lowercase(); if line.starts_with(&prefix) { buffer.extend(line[prefix.len()..].as_bytes()); return Ok(()); @@ -101,7 +103,7 @@ impl Config { match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) { Ok(mut f) => f.read_to_end(&mut buffer).map(|_| ())?, Err(_) => match root_dir.open_file("/CONFIG.TXT") { - Ok(f) => parse_config(key, &mut buffer, f)?, + Ok(mut f) => parse_config(key, &mut buffer, &mut f)?, Err(_) => return Err(Error::KeyNotFoundError(key)), }, }; @@ -124,11 +126,11 @@ impl Config { let prefix = [key, "="].concat().to_ascii_lowercase(); match root_dir.create_file("/CONFIG.TXT") { Ok(mut f) => { - let mut buffer = String::new(); - f.read_to_string(&mut buffer)?; + let mut buffer = Vec::new(); + f.read_to_end(&mut buffer)?; f.seek(SeekFrom::Start(0))?; f.truncate()?; - for line in buffer.lines() { + for line in String::from_utf8(buffer)?.lines() { if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix) { f.write(line.as_bytes())?; f.write(NEWLINE)?; diff --git a/libconfig/src/sd_reader.rs b/libconfig/src/sd_reader.rs index 5254a07..655bc94 100644 --- a/libconfig/src/sd_reader.rs +++ b/libconfig/src/sd_reader.rs @@ -1,4 +1,4 @@ -use core_io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write}; +use core2::io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write}; use fatfs; use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError}; use log::debug; diff --git a/szl/Cargo.toml b/szl/Cargo.toml index 958ae3a..6b97e4f 100644 --- a/szl/Cargo.toml +++ b/szl/Cargo.toml @@ -13,9 +13,9 @@ target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_ka default = ["target_zc706"] [dependencies] -log = "0.4" -byteorder = { version = "1.3", default-features = false } -core_io = { version = "0.1", features = ["collections"] } +log = "=0.4.14" +byteorder = { version = "=1.3", default-features = false } +core2 = { version = "=0.3.2", default-features = false, features = ["alloc", "nightly"] } libboard_zynq = { path = "../libboard_zynq" } libsupport_zynq = { path = "../libsupport_zynq" } diff --git a/szl/src/main.rs b/szl/src/main.rs index aafda8b..2729099 100644 --- a/szl/src/main.rs +++ b/szl/src/main.rs @@ -8,7 +8,7 @@ mod netboot; use alloc::rc::Rc; use core::mem; -use core_io::{Read, Seek}; +use core2::io::{Read, Seek}; use libboard_zynq::{ self as zynq, clocks::source::{ArmPll, ClockSource, IoPll}, diff --git a/szl/src/netboot.rs b/szl/src/netboot.rs index 8552a6e..ee91b62 100644 --- a/szl/src/netboot.rs +++ b/szl/src/netboot.rs @@ -1,7 +1,7 @@ use alloc::vec; use alloc::vec::Vec; use byteorder::{ByteOrder, NetworkEndian}; -use core_io::{Read, Seek}; +use core2::io::{Read, Seek}; use libboard_zynq::{ devc, eth::Eth,