Add async recursion fixes.
This commit is contained in:
parent
0d6460b01c
commit
48a62fc165
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -17,6 +17,17 @@ version = "2.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
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]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -291,6 +302,7 @@ dependencies = [
|
|||||||
name = "storage"
|
name = "storage"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-recursion",
|
||||||
"pack",
|
"pack",
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
@ -6,5 +6,6 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
tokio = { version = "1.44.1", features = ["full"] }
|
tokio = { version = "1.44.1", features = ["full"] }
|
||||||
|
async-recursion = "1.1.1"
|
||||||
|
|
||||||
pack = { git = "https://git.tsukiyo.org/Utility/pack" }
|
pack = { git = "https://git.tsukiyo.org/Utility/pack" }
|
||||||
|
@ -6,16 +6,18 @@ async fn main()
|
|||||||
{
|
{
|
||||||
std::fs::create_dir_all("data").ok();
|
std::fs::create_dir_all("data").ok();
|
||||||
|
|
||||||
/*
|
println!("BLOCKFILE");
|
||||||
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()) {
|
if let Ok(mut bf) = BlockFile::<16>::open("data/cache_data.bin").await {
|
||||||
let data = String::from_utf8(bf.get(id).unwrap()).unwrap();
|
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);
|
println!("id {} = '{}'", id, data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("Failed to open.");
|
println!("Failed to open.");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
println!("TRIEFILE");
|
||||||
|
|
||||||
if let Ok(mut tf) = TrieFile::<8>::open("data/cache_index.bin").await {
|
if let Ok(mut tf) = TrieFile::<8>::open("data/cache_index.bin").await {
|
||||||
|
|
||||||
|
@ -249,6 +249,7 @@ impl<const Z:usize> BlockFile<Z> {
|
|||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_recursion::async_recursion]
|
||||||
async fn allocate(&mut self, count:usize) -> Result<Vec<u32>, std::io::Error>
|
async fn allocate(&mut self, count:usize) -> Result<Vec<u32>, std::io::Error>
|
||||||
// Mark as allocated and return the next available N blocks.
|
// Mark as allocated and return the next available N blocks.
|
||||||
//
|
//
|
||||||
@ -278,6 +279,7 @@ impl<const Z:usize> BlockFile<Z> {
|
|||||||
Ok(blocks)
|
Ok(blocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_recursion::async_recursion]
|
||||||
async fn allocate_traverse(
|
async fn allocate_traverse(
|
||||||
&mut self,
|
&mut self,
|
||||||
block_id:u32,
|
block_id:u32,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user