improve on api

This commit is contained in:
NikVolf
2019-09-08 09:32:47 +03:00
parent c87122561f
commit a5c4d51652
3 changed files with 7 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ impl Entry {
})
}
pub fn from_bytes(consensus_branch_id: u32, buf: &[u8]) -> std::io::Result<Self> {
pub fn from_bytes<T: AsRef<[u8]>>(consensus_branch_id: u32, buf: T) -> std::io::Result<Self> {
let mut cursor = std::io::Cursor::new(buf);
Self::read(consensus_branch_id, &mut cursor)
}

View File

@@ -154,7 +154,7 @@ impl NodeData {
buf[0..pos].to_vec()
}
pub fn from_bytes(consensus_branch_id: u32, buf: &[u8]) -> std::io::Result<Self> {
pub fn from_bytes<T: AsRef<[u8]>>(consensus_branch_id: u32, buf: T) -> std::io::Result<Self> {
let mut cursor = std::io::Cursor::new(buf);
Self::read(consensus_branch_id, &mut cursor)
}

View File

@@ -267,7 +267,7 @@ impl Tree {
}
}
#[derive(Debug)]
pub struct IndexedNode<'a> {
node: &'a Entry,
link: EntryLink,
@@ -290,6 +290,10 @@ impl<'a> IndexedNode<'a> {
pub fn data(&self) -> &NodeData {
&self.node.data
}
pub fn link(&self) -> EntryLink {
self.link
}
}
fn combine_nodes<'a>(left: IndexedNode<'a>, right: IndexedNode<'a>) -> Entry {