From c13f577081c71006fb1645430d750fb2b2d0377f Mon Sep 17 00:00:00 2001 From: SSP Rust Developers <135766782+ssp-rs@users.noreply.github.com> Date: Fri, 22 Dec 2023 14:50:37 -0700 Subject: [PATCH] fixup: firmware: minor convenience functions Adds convenience functions to `FirmwareRam` for getting information about the backing buffer. --- src/types/firmware/ram.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/types/firmware/ram.rs b/src/types/firmware/ram.rs index 422d3f8..4240372 100644 --- a/src/types/firmware/ram.rs +++ b/src/types/firmware/ram.rs @@ -93,6 +93,16 @@ impl FirmwareRam { pub const fn index(&self) -> usize { self.index } + + /// Gets the length of the [FirmwareRam] buffer. + pub fn len(&self) -> usize { + self.block.len() + } + + /// Gets whether the [FirmwareRam] buffer is empty. + pub fn is_empty(&self) -> bool { + self.block.is_empty() + } } impl TryFrom<&[u8]> for FirmwareRam {