Remove alloc for extensions

This commit is contained in:
Tyler Beckman 2024-10-25 22:04:17 -06:00
parent 0904b73c12
commit 94a8343be7
Signed by: Ty
GPG key ID: 2813440C772555A4
2 changed files with 4 additions and 4 deletions

View file

@ -7,7 +7,7 @@ pub enum Version {
V1 = 0 V1 = 0
} }
pub type CtExtensions = Vec<u8>; pub type CtExtensions<'a> = &'a [u8];
#[repr(u8)] #[repr(u8)]
#[non_exhaustive] #[non_exhaustive]
@ -16,7 +16,7 @@ pub enum MerkleLeafType<'a> {
TimeStampedEntry { TimeStampedEntry {
timestamp: u64, timestamp: u64,
entry_type: LogEntryType<'a>, entry_type: LogEntryType<'a>,
extensions: CtExtensions extensions: CtExtensions<'a>
} = 0 } = 0
} }

View file

@ -95,14 +95,14 @@ pub fn parse_merkle_tree_leaf(
let ( let (
_, // no more to parse _, // no more to parse
ct_extensions // opaque CtExtensions<0..2^16-1> extensions // opaque CtExtensions<0..2^16-1>
) = nom::multi::length_data(nom::number::complete::be_u16)(input) ) = nom::multi::length_data(nom::number::complete::be_u16)(input)
.map_err(|e| e.map(|e| LeafParsingError::Nom(e)))?; .map_err(|e| e.map(|e| LeafParsingError::Nom(e)))?;
MerkleLeafType::TimeStampedEntry { MerkleLeafType::TimeStampedEntry {
timestamp, timestamp,
entry_type, entry_type,
extensions: ct_extensions.to_vec() extensions
} }
} }
_ => _ =>