wip datum

This commit is contained in:
2026-01-11 22:12:08 +01:00
parent 92f38c9c12
commit 8e279d9e24
2 changed files with 110 additions and 6 deletions

View File

@@ -208,7 +208,7 @@ impl ChunkNode {
// Helper struct
#[derive(Debug, Clone)]
pub struct DirectoryEntry {
pub filename: [u8; FILENAME_HASH_SIZE],
pub filename: Vec<u8>,
pub content_hash: NodeHash,
}
@@ -240,7 +240,7 @@ pub struct BigNode {
}
impl BigNode {
pub fn new(children_hashes: Vec<NodeHash>) -> Result<Self, String> {
/*pub fn new(children_hashes: Vec<NodeHash>) -> Result<Self, String> {
let n = children_hashes.len();
if n < MIN_BIG_CHILDREN || n > MAX_BIG_CHILDREN {
return Err(format!(
@@ -249,16 +249,17 @@ impl BigNode {
));
}
Ok(BigNode { children_hashes })
}
}*/
}
#[derive(Debug, Clone)]
pub struct BigDirectoryNode {
pub children_hashes: Vec<NodeHash>,
//pub children_hashes: Vec<NodeHash>,
pub children_hashes: Vec<DirectoryEntry>,
}
impl BigDirectoryNode {
pub fn new(children_hashes: Vec<NodeHash>) -> Result<Self, String> {
/*pub fn new(children_hashes: Vec<NodeHash>) -> Result<Self, String> {
let n = children_hashes.len();
if n < MIN_BIG_CHILDREN || n > MAX_BIG_CHILDREN {
return Err(format!(
@@ -267,6 +268,14 @@ impl BigDirectoryNode {
));
}
Ok(BigDirectoryNode { children_hashes })
}*/
pub fn new(entries: Vec<DirectoryEntry>) -> Result<Self, String> {
if entries.len() > MAX_DIRECTORY_ENTRIES {
return Err(format!("Directory exceeds {} bytes", entries.len()));
}
Ok(BigDirectoryNode {
children_hashes: entries,
})
}
}