Add async recursion fixes.

This commit is contained in:
yukirij 2025-04-13 12:14:15 -07:00
parent 0d6460b01c
commit 48a62fc165
4 changed files with 22 additions and 5 deletions

12
Cargo.lock generated
View File

@ -17,6 +17,17 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "async-recursion"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "autocfg"
version = "1.4.0"
@ -291,6 +302,7 @@ dependencies = [
name = "storage"
version = "0.1.0"
dependencies = [
"async-recursion",
"pack",
"tokio",
]

View File

@ -6,5 +6,6 @@ edition = "2021"
[dependencies]
tokio = { version = "1.44.1", features = ["full"] }
async-recursion = "1.1.1"
pack = { git = "https://git.tsukiyo.org/Utility/pack" }

View File

@ -6,16 +6,18 @@ async fn main()
{
std::fs::create_dir_all("data").ok();
/*
if let Ok(mut bf) = BlockFile::<16>::open("data/cache_data.bin") {
if let Ok(id) = bf.insert("This is a test of the block file system.".as_bytes()) {
let data = String::from_utf8(bf.get(id).unwrap()).unwrap();
println!("BLOCKFILE");
if let Ok(mut bf) = BlockFile::<16>::open("data/cache_data.bin").await {
if let Ok(id) = bf.insert("This is a test of the block file system.".as_bytes()).await {
let data = String::from_utf8(bf.get(id).await.unwrap()).unwrap();
println!("id {} = '{}'", id, data);
}
} else {
println!("Failed to open.");
}
*/
println!("TRIEFILE");
if let Ok(mut tf) = TrieFile::<8>::open("data/cache_index.bin").await {

View File

@ -249,6 +249,7 @@ impl<const Z:usize> BlockFile<Z> {
Ok(output)
}
#[async_recursion::async_recursion]
async fn allocate(&mut self, count:usize) -> Result<Vec<u32>, std::io::Error>
// Mark as allocated and return the next available N blocks.
//
@ -278,6 +279,7 @@ impl<const Z:usize> BlockFile<Z> {
Ok(blocks)
}
#[async_recursion::async_recursion]
async fn allocate_traverse(
&mut self,
block_id:u32,