Snap for 11162593 from 1eedf43d11ef8237823fdfe73b80127c1f2f9b0c to 24Q1-release

Change-Id: I97a69a7c20206dcf2994d99a924d49939185a12e
diff --git a/rust/src/error.rs b/rust/src/error.rs
index b5d781e..1e78f5e 100644
--- a/rust/src/error.rs
+++ b/rust/src/error.rs
@@ -60,6 +60,15 @@
     Internal,
 }
 
+/// `Result` type for `SlotVerifyError` errors.
+pub type SlotVerifyResult<'a, T> = Result<T, SlotVerifyError<'a>>;
+
+/// `Result` type for `SlotVerifyError` errors without any `SlotVerifyData`.
+///
+/// If the contained error will never hold a `SlotVerifyData`, this is easier to work with compared
+/// to `SlotVerifyResult` due to the static lifetime bound.
+pub type SlotVerifyNoDataResult<T> = SlotVerifyResult<'static, T>;
+
 impl<'a> SlotVerifyError<'a> {
     /// Returns a copy of this error without any contained `SlotVerifyData`.
     ///
@@ -109,9 +118,7 @@
 ///
 /// TODO(b/290110273): this can be limited to pub(crate) once we've moved the full libavb wrapper
 /// here.
-pub fn slot_verify_enum_to_result(
-    result: AvbSlotVerifyResult,
-) -> Result<(), SlotVerifyError<'static>> {
+pub fn slot_verify_enum_to_result(result: AvbSlotVerifyResult) -> SlotVerifyNoDataResult<()> {
     match result {
         AvbSlotVerifyResult::AVB_SLOT_VERIFY_RESULT_OK => Ok(()),
         AvbSlotVerifyResult::AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT => {
@@ -159,6 +166,9 @@
     NotImplemented,
 }
 
+/// `Result` type for `IoError` errors.
+pub type IoResult<T> = Result<T, IoError>;
+
 impl fmt::Display for IoError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
@@ -183,11 +193,10 @@
 // Converts a bindgen `AvbIOResult` enum to a `Result<>`, mapping `AVB_IO_RESULT_OK` to the Rust
 // equivalent `Ok(())` and errors to the corresponding `Err(IoError)`.
 //
-// This function is also important to serve as a compile-time check that we're handling all the
-// libavb enums; if a new one is added to (or removed from) the C code, this will fail to compile
+// This function is not currently used, but serves as a compile-time check that we're handling all
+// the libavb enums; if a new one is added to or removed from the C code, this will fail to compile
 // until it is updated to match.
-#[allow(dead_code)]
-pub(crate) fn io_enum_to_result(result: AvbIOResult) -> Result<(), IoError> {
+fn io_enum_to_result(result: AvbIOResult) -> IoResult<()> {
     match result {
         AvbIOResult::AVB_IO_RESULT_OK => Ok(()),
         AvbIOResult::AVB_IO_RESULT_ERROR_OOM => Err(IoError::Oom),
@@ -249,6 +258,9 @@
     SignatureMismatch,
 }
 
+/// `Result` type for `VbmetaVerifyError` errors.
+pub type VbmetaVerifyResult<T> = Result<T, VbmetaVerifyError>;
+
 impl fmt::Display for VbmetaVerifyError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
@@ -268,9 +280,7 @@
 // This function is also important to serve as a compile-time check that we're handling all the
 // libavb enums; if a new one is added to (or removed from) the C code, this will fail to compile
 // until it is updated to match.
-pub fn vbmeta_verify_enum_to_result(
-    result: AvbVBMetaVerifyResult,
-) -> Result<(), VbmetaVerifyError> {
+pub fn vbmeta_verify_enum_to_result(result: AvbVBMetaVerifyResult) -> VbmetaVerifyResult<()> {
     match result {
         AvbVBMetaVerifyResult::AVB_VBMETA_VERIFY_RESULT_OK => Ok(()),
         AvbVBMetaVerifyResult::AVB_VBMETA_VERIFY_RESULT_OK_NOT_SIGNED => {
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index c580497..63c3818 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -30,7 +30,10 @@
 mod ops;
 mod verify;
 
-pub use error::{IoError, SlotVerifyError};
+pub use error::{
+    IoError, IoResult, SlotVerifyError, SlotVerifyNoDataResult, SlotVerifyResult,
+    VbmetaVerifyError, VbmetaVerifyResult,
+};
 pub use ops::{Ops, PublicKeyForPartitionInfo};
 pub use verify::{
     slot_verify, HashtreeErrorMode, PartitionData, SlotVerifyData, SlotVerifyFlags, VbmetaData,
diff --git a/rust/src/ops.rs b/rust/src/ops.rs
index f613fb5..005aa98 100644
--- a/rust/src/ops.rs
+++ b/rust/src/ops.rs
@@ -19,7 +19,7 @@
 
 extern crate alloc;
 
-use crate::{error::result_to_io_enum, IoError};
+use crate::{error::result_to_io_enum, IoError, IoResult};
 use avb_bindgen::{AvbIOResult, AvbOps};
 use core::{
     cmp::min,
@@ -30,9 +30,6 @@
 #[cfg(feature = "uuid")]
 use uuid::Uuid;
 
-/// Common `Result` type for `IoError` errors.
-type Result<T> = core::result::Result<T, IoError>;
-
 /// Base implementation-provided callbacks for verification.
 ///
 /// See libavb `AvbOps` for more complete documentation.
@@ -54,7 +51,7 @@
         partition: &CStr,
         offset: i64,
         buffer: &mut [u8],
-    ) -> Result<usize>;
+    ) -> IoResult<usize>;
 
     /// Returns a reference to preloaded partition contents.
     ///
@@ -71,7 +68,7 @@
     /// * `Err<IoError::NotImplemented>` if the requested partition has not been preloaded;
     ///   verification will next attempt to load the partition via `read_from_partition()`.
     /// * Any other `Err<IoError>` if an error occurred; verification will exit immediately.
-    fn get_preloaded_partition(&mut self, partition: &CStr) -> Result<&[u8]> {
+    fn get_preloaded_partition(&mut self, partition: &CStr) -> IoResult<&[u8]> {
         Err(IoError::NotImplemented)
     }
 
@@ -88,7 +85,7 @@
         &mut self,
         public_key: &[u8],
         public_key_metadata: Option<&[u8]>,
-    ) -> Result<bool>;
+    ) -> IoResult<bool>;
 
     /// Reads the rollback index at the given location.
     ///
@@ -97,7 +94,7 @@
     ///
     /// # Returns
     /// The rollback index at this location or `IoError` on error.
-    fn read_rollback_index(&mut self, rollback_index_location: usize) -> Result<u64>;
+    fn read_rollback_index(&mut self, rollback_index_location: usize) -> IoResult<u64>;
 
     /// Writes the rollback index at the given location.
     ///
@@ -113,13 +110,13 @@
     ///
     /// # Returns
     /// Unit on success or `IoError` on error.
-    fn write_rollback_index(&mut self, rollback_index_location: usize, index: u64) -> Result<()>;
+    fn write_rollback_index(&mut self, rollback_index_location: usize, index: u64) -> IoResult<()>;
 
     /// Returns the device unlock state.
     ///
     /// # Returns
     /// True if the device is unlocked, false if locked, `IoError` on error.
-    fn read_is_device_unlocked(&mut self) -> Result<bool>;
+    fn read_is_device_unlocked(&mut self) -> IoResult<bool>;
 
     /// Returns the GUID of the requested partition.
     ///
@@ -134,7 +131,7 @@
     /// # Returns
     /// The partition GUID or `IoError` on error.
     #[cfg(feature = "uuid")]
-    fn get_unique_guid_for_partition(&mut self, partition: &CStr) -> Result<Uuid>;
+    fn get_unique_guid_for_partition(&mut self, partition: &CStr) -> IoResult<Uuid>;
 
     /// Returns the size of the requested partition.
     ///
@@ -143,7 +140,7 @@
     ///
     /// # Returns
     /// The partition size in bytes or `IoError` on error.
-    fn get_size_of_partition(&mut self, partition: &CStr) -> Result<u64>;
+    fn get_size_of_partition(&mut self, partition: &CStr) -> IoResult<u64>;
 
     /// Reads the requested persistent value.
     ///
@@ -163,7 +160,7 @@
     /// * `IoError::NoSuchValue` if `name` is not a known persistent value.
     /// * `IoError::InsufficientSpace` with the required size if the `value` buffer is too small.
     /// * Any other `IoError` on failure.
-    fn read_persistent_value(&mut self, name: &CStr, value: &mut [u8]) -> Result<usize>;
+    fn read_persistent_value(&mut self, name: &CStr, value: &mut [u8]) -> IoResult<usize>;
 
     /// Writes the requested persistent value.
     ///
@@ -180,7 +177,7 @@
     /// * `IoError::NoSuchValue` if `name` is not a supported persistent value.
     /// * `IoError::InvalidValueSize` if `value` is too large to save as a persistent value.
     /// * Any other `IoError` on failure.
-    fn write_persistent_value(&mut self, name: &CStr, value: &[u8]) -> Result<()>;
+    fn write_persistent_value(&mut self, name: &CStr, value: &[u8]) -> IoResult<()>;
 
     /// Erases the requested persistent value.
     ///
@@ -198,7 +195,7 @@
     /// * Unit on success.
     /// * `IoError::NoSuchValue` if `name` is not a supported persistent value.
     /// * Any other `IoError` on failure.
-    fn erase_persistent_value(&mut self, name: &CStr) -> Result<()>;
+    fn erase_persistent_value(&mut self, name: &CStr) -> IoResult<()>;
 
     /// Checks if the given public key is valid for the given partition.
     ///
@@ -223,7 +220,7 @@
         partition: &CStr,
         public_key: &[u8],
         public_key_metadata: Option<&[u8]>,
-    ) -> Result<PublicKeyForPartitionInfo>;
+    ) -> IoResult<PublicKeyForPartitionInfo>;
 }
 
 /// Info returned from `validare_public_key_for_partition()`.
@@ -348,7 +345,7 @@
 ///
 /// In practice, these conditions are met since we call this exactly once in each callback
 /// to extract the `Ops`, and drop it at callback completion.
-unsafe fn as_ops<'a>(avb_ops: *mut AvbOps) -> Result<&'a mut dyn Ops> {
+unsafe fn as_ops<'a>(avb_ops: *mut AvbOps) -> IoResult<&'a mut dyn Ops> {
     // SAFETY: we created this AvbOps object and passed it to libavb so we know it meets all
     // the criteria for `as_mut()`.
     let avb_ops = unsafe { avb_ops.as_mut() }.ok_or(IoError::Io)?;
@@ -360,14 +357,14 @@
 }
 
 /// Converts a non-NULL `ptr` to `()`, NULL to `Err(IoError::Io)`.
-fn check_nonnull<T>(ptr: *const T) -> Result<()> {
+fn check_nonnull<T>(ptr: *const T) -> IoResult<()> {
     match ptr.is_null() {
         true => Err(IoError::Io),
         false => Ok(()),
     }
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn read_from_partition(
@@ -402,7 +399,7 @@
     num_bytes: usize,
     buffer: *mut c_void,
     out_num_read: *mut usize,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(partition)?;
     check_nonnull(buffer)?;
     check_nonnull(out_num_read)?;
@@ -438,7 +435,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn get_preloaded_partition(
@@ -471,7 +468,7 @@
     num_bytes: usize,
     out_pointer: *mut *mut u8,
     out_num_bytes_preloaded: *mut usize,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(partition)?;
     check_nonnull(out_pointer)?;
     check_nonnull(out_num_bytes_preloaded)?;
@@ -522,7 +519,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn validate_vbmeta_public_key(
@@ -556,7 +553,7 @@
     public_key_metadata: *const u8,
     public_key_metadata_length: usize,
     out_is_trusted: *mut bool,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(public_key_data)?;
     check_nonnull(out_is_trusted)?;
 
@@ -595,7 +592,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn read_rollback_index(
@@ -619,7 +616,7 @@
     ops: *mut AvbOps,
     rollback_index_location: usize,
     out_rollback_index: *mut u64,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(out_rollback_index)?;
 
     // Initialize the output variables first in case something fails.
@@ -641,7 +638,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn write_rollback_index(
@@ -664,7 +661,7 @@
     ops: *mut AvbOps,
     rollback_index_location: usize,
     rollback_index: u64,
-) -> Result<()> {
+) -> IoResult<()> {
     // SAFETY:
     // * we only use `ops` objects created via `ScopedAvbOps` as required.
     // * `ops` is only extracted once and is dropped at the end of the callback.
@@ -672,7 +669,7 @@
     ops.write_rollback_index(rollback_index_location, rollback_index)
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn read_is_device_unlocked(
@@ -687,7 +684,10 @@
 /// # Safety
 /// * `ops` must have been created via `ScopedAvbOps`.
 /// * `out_is_unlocked` must adhere to the requirements of `ptr::write()`.
-unsafe fn try_read_is_device_unlocked(ops: *mut AvbOps, out_is_unlocked: *mut bool) -> Result<()> {
+unsafe fn try_read_is_device_unlocked(
+    ops: *mut AvbOps,
+    out_is_unlocked: *mut bool,
+) -> IoResult<()> {
     check_nonnull(out_is_unlocked)?;
 
     // Initialize the output variables first in case something fails.
@@ -709,7 +709,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn get_unique_guid_for_partition(
@@ -737,7 +737,7 @@
     partition: *const c_char,
     guid_buf: *mut c_char,
     guid_buf_size: usize,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(partition)?;
     check_nonnull(guid_buf)?;
 
@@ -794,7 +794,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn get_size_of_partition(
@@ -819,7 +819,7 @@
     ops: *mut AvbOps,
     partition: *const c_char,
     out_size_num_bytes: *mut u64,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(partition)?;
     check_nonnull(out_size_num_bytes)?;
 
@@ -848,7 +848,7 @@
     Ok(())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn read_persistent_value(
@@ -880,7 +880,7 @@
     buffer_size: usize,
     out_buffer: *mut u8,
     out_num_bytes_read: *mut usize,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(name)?;
     check_nonnull(out_num_bytes_read)?;
 
@@ -926,7 +926,7 @@
     result.map(|_| ())
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn write_persistent_value(
@@ -949,7 +949,7 @@
     name: *const c_char,
     value_size: usize,
     value: *const u8,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(name)?;
 
     // SAFETY:
@@ -977,7 +977,7 @@
     }
 }
 
-/// Wraps a callback to convert the given `Result<>` to raw `AvbIOResult` for libavb.
+/// Wraps a callback to convert the given `IoResult<>` to raw `AvbIOResult` for libavb.
 ///
 /// See corresponding `try_*` function docs.
 unsafe extern "C" fn validate_public_key_for_partition(
@@ -1018,7 +1018,7 @@
     public_key_metadata_length: usize,
     out_is_trusted: *mut bool,
     out_rollback_index_location: *mut u32,
-) -> Result<()> {
+) -> IoResult<()> {
     check_nonnull(partition)?;
     check_nonnull(public_key_data)?;
     check_nonnull(out_is_trusted)?;
diff --git a/rust/src/verify.rs b/rust/src/verify.rs
index 62ecf0b..288aed2 100644
--- a/rust/src/verify.rs
+++ b/rust/src/verify.rs
@@ -20,7 +20,7 @@
 use crate::{
     error::{
         slot_verify_enum_to_result, vbmeta_verify_enum_to_result, SlotVerifyError,
-        VbmetaVerifyError,
+        SlotVerifyNoDataResult, SlotVerifyResult, VbmetaVerifyResult,
     },
     ops, IoError, Ops,
 };
@@ -41,7 +41,7 @@
 pub use avb_bindgen::AvbSlotVerifyFlags as SlotVerifyFlags;
 
 /// Returns `Err(SlotVerifyError::Internal)` if the given pointer is `NULL`.
-fn check_nonnull<T>(ptr: *const T) -> Result<(), SlotVerifyError<'static>> {
+fn check_nonnull<T>(ptr: *const T) -> SlotVerifyNoDataResult<()> {
     match ptr.is_null() {
         true => Err(SlotVerifyError::Internal),
         false => Ok(()),
@@ -66,7 +66,7 @@
     /// objects ourselves, we just cast them from the C structs provided by libavb.
     ///
     /// Returns `Err(SlotVerifyError::Internal)` on failure.
-    fn validate(&self) -> Result<(), SlotVerifyError<'static>> {
+    fn validate(&self) -> SlotVerifyNoDataResult<()> {
         check_nonnull(self.0.partition_name)?;
         check_nonnull(self.0.vbmeta_data)?;
         Ok(())
@@ -89,7 +89,7 @@
     }
 
     /// Returns the vbmeta verification result.
-    pub fn verify_result(&self) -> Result<(), VbmetaVerifyError> {
+    pub fn verify_result(&self) -> VbmetaVerifyResult<()> {
         vbmeta_verify_enum_to_result(self.0.verify_result)
     }
 }
@@ -122,7 +122,7 @@
     /// objects ourselves, we just cast them from the C structs provided by libavb.
     ///
     /// Returns `Err(SlotVerifyError::Internal)` on failure.
-    fn validate(&self) -> Result<(), SlotVerifyError<'static>> {
+    fn validate(&self) -> SlotVerifyNoDataResult<()> {
         check_nonnull(self.0.partition_name)?;
         check_nonnull(self.0.data)?;
         Ok(())
@@ -153,7 +153,7 @@
     ///
     /// Only top-level `Verification` errors will contain valid `SlotVerifyData` objects, if this
     /// individual partition returns a `Verification` error the error will always contain `None`.
-    pub fn verify_result(&self) -> Result<(), SlotVerifyError<'static>> {
+    pub fn verify_result(&self) -> SlotVerifyNoDataResult<()> {
         slot_verify_enum_to_result(self.0.verify_result)
     }
 }
@@ -215,7 +215,7 @@
     unsafe fn new(
         data: *mut AvbSlotVerifyData,
         ops: &'a mut dyn Ops,
-    ) -> Result<Self, SlotVerifyError<'static>> {
+    ) -> SlotVerifyNoDataResult<Self> {
         let ret = Self {
             raw_data: NonNull::new(data).ok_or(SlotVerifyError::Internal)?,
             _ops: PhantomData,
@@ -356,7 +356,7 @@
     ab_suffix: Option<&CStr>,
     flags: SlotVerifyFlags,
     hashtree_error_mode: HashtreeErrorMode,
-) -> Result<SlotVerifyData<'a>, SlotVerifyError<'a>> {
+) -> SlotVerifyResult<'a, SlotVerifyData<'a>> {
     let mut user_data = ops::UserData::new(ops);
     let mut scoped_ops = ops::ScopedAvbOps::new(&mut user_data);
     let avb_ops = scoped_ops.as_mut();
diff --git a/rust/tests/test_ops.rs b/rust/tests/test_ops.rs
index 1e1ad1b..aa8c579 100644
--- a/rust/tests/test_ops.rs
+++ b/rust/tests/test_ops.rs
@@ -14,14 +14,11 @@
 
 //! Provides `avb::Ops` test fixtures.
 
-use avb::{IoError, Ops, PublicKeyForPartitionInfo};
+use avb::{IoError, IoResult, Ops, PublicKeyForPartitionInfo};
 use std::{cmp::min, collections::HashMap, ffi::CStr};
 #[cfg(feature = "uuid")]
 use uuid::Uuid;
 
-/// Common `Result` type for `IoError` errors.
-type Result<T> = core::result::Result<T, IoError>;
-
 /// Represents a single fake partition.
 #[derive(Default)]
 pub struct FakePartition {
@@ -64,12 +61,12 @@
     pub rollbacks: HashMap<usize, u64>,
 
     /// Unlock state. Set an error to simulate IoError during access.
-    pub unlock_state: Result<bool>,
+    pub unlock_state: IoResult<bool>,
 
     /// Persistent named values. Set an error to simulate `IoError` during access. Writing
     /// a non-existent persistent value will create it; to simulate `NoSuchValue` instead,
     /// create an entry with `Err(IoError::NoSuchValue)` as the value.
-    pub persistent_values: HashMap<String, Result<Vec<u8>>>,
+    pub persistent_values: HashMap<String, IoResult<Vec<u8>>>,
 }
 
 impl TestOps {
@@ -105,7 +102,7 @@
     /// test_ops.add_persistent_value("foo", Ok(b"contents"));
     /// test_ops.add_persistent_value("bar", Err(IoError::NoSuchValue));
     /// ```
-    pub fn add_persistent_value(&mut self, name: &str, contents: Result<&[u8]>) {
+    pub fn add_persistent_value(&mut self, name: &str, contents: IoResult<&[u8]>) {
         self.persistent_values
             .insert(name.into(), contents.map(|b| b.into()));
     }
@@ -166,7 +163,7 @@
         partition: &CStr,
         offset: i64,
         buffer: &mut [u8],
-    ) -> Result<usize> {
+    ) -> IoResult<usize> {
         let partition = self
             .partitions
             .get(partition.to_str()?)
@@ -205,7 +202,7 @@
         Ok(bytes_read)
     }
 
-    fn get_preloaded_partition(&mut self, partition: &CStr) -> Result<&[u8]> {
+    fn get_preloaded_partition(&mut self, partition: &CStr) -> IoResult<&[u8]> {
         match self.partitions.get(partition.to_str()?) {
             Some(FakePartition {
                 contents,
@@ -220,7 +217,7 @@
         &mut self,
         public_key: &[u8],
         public_key_metadata: Option<&[u8]>,
-    ) -> Result<bool> {
+    ) -> IoResult<bool> {
         self.vbmeta_keys
             // The compiler can't match (&[u8], Option<&[u8]>) to keys of type
             // (Vec<u8>, Option<Vec<u8>>) so we turn the &[u8] into vectors here. This is a bit
@@ -230,35 +227,35 @@
             .map(|k| k.info.trusted)
     }
 
-    fn read_rollback_index(&mut self, location: usize) -> Result<u64> {
+    fn read_rollback_index(&mut self, location: usize) -> IoResult<u64> {
         self.rollbacks.get(&location).ok_or(IoError::Io).copied()
     }
 
-    fn write_rollback_index(&mut self, location: usize, index: u64) -> Result<()> {
+    fn write_rollback_index(&mut self, location: usize, index: u64) -> IoResult<()> {
         *(self.rollbacks.get_mut(&location).ok_or(IoError::Io)?) = index;
         Ok(())
     }
 
-    fn read_is_device_unlocked(&mut self) -> Result<bool> {
+    fn read_is_device_unlocked(&mut self) -> IoResult<bool> {
         self.unlock_state.clone()
     }
 
     #[cfg(feature = "uuid")]
-    fn get_unique_guid_for_partition(&mut self, partition: &CStr) -> Result<Uuid> {
+    fn get_unique_guid_for_partition(&mut self, partition: &CStr) -> IoResult<Uuid> {
         self.partitions
             .get(partition.to_str()?)
             .map(|p| p.uuid)
             .ok_or(IoError::NoSuchPartition)
     }
 
-    fn get_size_of_partition(&mut self, partition: &CStr) -> Result<u64> {
+    fn get_size_of_partition(&mut self, partition: &CStr) -> IoResult<u64> {
         self.partitions
             .get(partition.to_str()?)
             .map(|p| u64::try_from(p.contents.len()).unwrap())
             .ok_or(IoError::NoSuchPartition)
     }
 
-    fn read_persistent_value(&mut self, name: &CStr, value: &mut [u8]) -> Result<usize> {
+    fn read_persistent_value(&mut self, name: &CStr, value: &mut [u8]) -> IoResult<usize> {
         match self
             .persistent_values
             .get(name.to_str()?)
@@ -276,7 +273,7 @@
         }
     }
 
-    fn write_persistent_value(&mut self, name: &CStr, value: &[u8]) -> Result<()> {
+    fn write_persistent_value(&mut self, name: &CStr, value: &[u8]) -> IoResult<()> {
         let name = name.to_str()?;
 
         // If the test requested a simulated error on this value, return it.
@@ -289,7 +286,7 @@
         Ok(())
     }
 
-    fn erase_persistent_value(&mut self, name: &CStr) -> Result<()> {
+    fn erase_persistent_value(&mut self, name: &CStr) -> IoResult<()> {
         let name = name.to_str()?;
 
         // If the test requested a simulated error on this value, return it.
@@ -306,7 +303,7 @@
         partition: &CStr,
         public_key: &[u8],
         public_key_metadata: Option<&[u8]>,
-    ) -> Result<PublicKeyForPartitionInfo> {
+    ) -> IoResult<PublicKeyForPartitionInfo> {
         let key = self
             .vbmeta_keys
             .get(&(public_key.to_vec(), public_key_metadata.map(|m| m.to_vec())))
diff --git a/rust/tests/verify_tests.rs b/rust/tests/verify_tests.rs
index 416e0ec..13d4912 100644
--- a/rust/tests/verify_tests.rs
+++ b/rust/tests/verify_tests.rs
@@ -17,6 +17,7 @@
 use crate::test_ops::TestOps;
 use avb::{
     slot_verify, HashtreeErrorMode, IoError, SlotVerifyData, SlotVerifyError, SlotVerifyFlags,
+    SlotVerifyResult,
 };
 use std::{ffi::CString, fs};
 #[cfg(feature = "uuid")]
@@ -50,9 +51,7 @@
 }
 
 /// Calls `slot_verify()` using standard args for `test_ops_one_image_one_vbmeta()` setup.
-fn verify_one_image_one_vbmeta<'a>(
-    ops: &'a mut TestOps,
-) -> Result<SlotVerifyData<'a>, SlotVerifyError<'a>> {
+fn verify_one_image_one_vbmeta(ops: &mut TestOps) -> SlotVerifyResult<SlotVerifyData> {
     slot_verify(
         ops,
         &[&CString::new(TEST_PARTITION_NAME).unwrap()],
@@ -74,9 +73,7 @@
 }
 
 /// Calls `slot_verify()` using standard args for `test_ops_two_images_one_vbmeta()` setup.
-fn verify_two_images_one_vbmeta<'a>(
-    ops: &'a mut TestOps,
-) -> Result<SlotVerifyData<'a>, SlotVerifyError<'a>> {
+fn verify_two_images_one_vbmeta(ops: &mut TestOps) -> SlotVerifyResult<SlotVerifyData> {
     slot_verify(
         ops,
         &[
@@ -102,9 +99,7 @@
 }
 
 /// Calls `slot_verify()` using standard args for `test_ops_boot_partition()` setup.
-fn verify_boot_partition<'a>(
-    ops: &'a mut TestOps,
-) -> Result<SlotVerifyData<'a>, SlotVerifyError<'a>> {
+fn verify_boot_partition(ops: &mut TestOps) -> SlotVerifyResult<SlotVerifyData> {
     slot_verify(
         ops,
         &[&CString::new("boot").unwrap()],
@@ -133,9 +128,7 @@
 }
 
 /// Calls `slot_verify()` using standard args for `test_ops_persistent_digest()` setup.
-fn verify_persistent_digest<'a>(
-    ops: &'a mut TestOps,
-) -> Result<SlotVerifyData<'a>, SlotVerifyError<'a>> {
+fn verify_persistent_digest(ops: &mut TestOps) -> SlotVerifyResult<SlotVerifyData> {
     slot_verify(
         ops,
         &[&CString::new(TEST_PARTITION_PERSISTENT_DIGEST_NAME).unwrap()],