Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/primitives/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ impl Bytecode {
!matches!(self, Self::LegacyRaw(_))
}

/// Returns bytes
#[inline]
pub fn bytes(&self) -> Bytes {
match self {
Self::LegacyRaw(bytes) => bytes.clone(),
Self::LegacyAnalyzed(analyzed) => analyzed.bytecode().clone(),
Self::Eof(eof) => eof.raw().clone(),
}
}

/// Returns bytes slice
#[inline]
pub fn bytes_slice(&self) -> &[u8] {
match self {
Self::LegacyRaw(bytes) => bytes,
Self::LegacyAnalyzed(analyzed) => analyzed.bytecode(),
Self::Eof(eof) => eof.raw(),
}
}

/// Returns a reference to the original bytecode.
#[inline]
pub fn original_bytes(&self) -> Bytes {
Expand Down