From 6d9deefb934f11c91f751618fd86a5a0dbe86570 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Sat, 7 Sep 2019 14:10:08 +0300 Subject: [PATCH] fix read and add from_bytes --- src/entry.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/entry.rs b/src/entry.rs index 485b364..59663fc 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -42,7 +42,7 @@ impl Entry { } } - pub fn read(&self, consensus_branch_id: u32, r: &mut R) -> std::io::Result { + pub fn read(consensus_branch_id: u32, r: &mut R) -> std::io::Result { let kind = { match r.read_u8()? { 0 => { @@ -66,6 +66,11 @@ impl Entry { data, }) } + + pub fn from_bytes(consensus_branch_id: u32, buf: &[u8]) -> std::io::Result { + let mut cursor = std::io::Cursor::new(buf); + Self::read(consensus_branch_id, &mut cursor) + } } impl From for Entry {