From 3e75276e2dbd19fab9ac5c61c96b2da92b9d737b Mon Sep 17 00:00:00 2001 From: Nicolas Stalder Date: Mon, 13 Apr 2020 02:39:30 +0200 Subject: [PATCH] Remove heapless-bytes --- Cargo.toml | 4 ++-- netlify.toml | 3 ++- src/fsc.rs | 33 +++++++++++++++++++++++++++++++++ src/path.rs | 11 +++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1898f50e..9572096a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ bitflags = "1.0.4" cty = "0.2.1" generic-array = "0.13.2" # heapless = "0.5.1" -heapless-bytes = { path = "../heapless-bytes", optional = true } +# heapless-bytes = { path = "../heapless-bytes", optional = true } # Listed as regular dependency behind feature flag, # since dev-dependencies cannot be optional, and we @@ -45,7 +45,7 @@ serde = { version = "1.0", default-features = false, features = ["derive"] } [features] # default = ["closures"] # use experimental closure-based API -closures = ["aligned", "heapless-bytes"] +closures = ["aligned"] # , "heapless-bytes"] dir-entry-path = [] # enable assertions in backend C code ll-assertions = ["littlefs2-sys/assertions"] diff --git a/netlify.toml b/netlify.toml index 3f414333..8721cd8a 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,6 @@ [build] - command = "curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && sudo apt-get install llvm && cargo doc" + # command = "curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && sudo apt-get install llvm && cargo doc" + command = "curl https://sh.rustup.rs -sSf | sh -s -- -y && source $HOME/.cargo/env && env && cargo doc" publish = "target/doc" [[redirects]] diff --git a/src/fsc.rs b/src/fsc.rs index 6dfe5ccf..4aa3bfa1 100644 --- a/src/fsc.rs +++ b/src/fsc.rs @@ -1262,6 +1262,39 @@ mod tests { fs.write("/z.txt", &jackson5).unwrap(); } + #[test] + fn nested() { + let mut test_storage = TestStorage::new(); + + Filesystem::format(&mut test_storage).unwrap(); + Filesystem::mount_and_then(&mut test_storage, |fs| { + + fs.write("a.txt", &[])?; + fs.write("b.txt", &[])?; + fs.write("c.txt", &[])?; + + fs.read_dir_and_then(".", |read_dir| { + for entry in read_dir { + let entry = entry?; + println!("{:?}", entry.file_type()); + + // The `&mut ReadDir` is not actually available here + // Do we want a way to borrow_filesystem for DirEntry? + // One usecase is to read data from the files iterated over. + // + // unsafe { read_dir.borrow_filesystem() }.write( + // &entry.file_name()[..], + // b"wowee zowie" + // )?; + } + Ok(()) + })?; + + Ok(()) + }).unwrap(); + } + + #[test] fn issue_3_original_report() { let mut test_storage = TestStorage::new(); diff --git a/src/path.rs b/src/path.rs index 944c9a8b..c32add30 100644 --- a/src/path.rs +++ b/src/path.rs @@ -22,6 +22,17 @@ where ::FILENAME_MAX_PLUS_ONE: ArrayLength, ; +impl core::ops::Deref for Filename +where + S: driver::Storage, + ::FILENAME_MAX_PLUS_ONE: ArrayLength, +{ + type Target = [u8]; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + // to compare filename impl cmp::PartialEq for Filename where