avb: move error module to libavb
The libavb Rust wrappers are moving to //external/avb to make them more
widely available and keep them closer to the C source.
To keep CLs manageable, this is being done in smaller chunks. This first
CL just moves the error module over.
A few minor changes were necessary to split out some pvmfw-specific
error conditions from the generic libavb errors (e.g. requirements on
the shape of the vbmeta image).
Bug: b/290110273
Test: atest results unchanged from pre-patch
Change-Id: Iacef297bfb72e560890971e9e158c55f46cf0583
diff --git a/pvmfw/avb/src/partition.rs b/pvmfw/avb/src/partition.rs
index bc63003..ca450c9 100644
--- a/pvmfw/avb/src/partition.rs
+++ b/pvmfw/avb/src/partition.rs
@@ -14,7 +14,6 @@
//! Struct and functions relating to well-known partition names.
-use crate::error::AvbIOError;
use crate::utils::is_not_null;
use core::ffi::{c_char, CStr};
@@ -53,7 +52,7 @@
}
impl TryFrom<*const c_char> for PartitionName {
- type Error = AvbIOError;
+ type Error = avb::IoError;
fn try_from(partition_name: *const c_char) -> Result<Self, Self::Error> {
is_not_null(partition_name)?;
@@ -64,27 +63,27 @@
}
impl TryFrom<&CStr> for PartitionName {
- type Error = AvbIOError;
+ type Error = avb::IoError;
fn try_from(partition_name: &CStr) -> Result<Self, Self::Error> {
match partition_name.to_bytes_with_nul() {
Self::KERNEL_PARTITION_NAME => Ok(Self::Kernel),
Self::INITRD_NORMAL_PARTITION_NAME => Ok(Self::InitrdNormal),
Self::INITRD_DEBUG_PARTITION_NAME => Ok(Self::InitrdDebug),
- _ => Err(AvbIOError::NoSuchPartition),
+ _ => Err(avb::IoError::NoSuchPartition),
}
}
}
impl TryFrom<&[u8]> for PartitionName {
- type Error = AvbIOError;
+ type Error = avb::IoError;
fn try_from(non_null_terminated_name: &[u8]) -> Result<Self, Self::Error> {
match non_null_terminated_name {
x if x == Self::Kernel.as_non_null_terminated_bytes() => Ok(Self::Kernel),
x if x == Self::InitrdNormal.as_non_null_terminated_bytes() => Ok(Self::InitrdNormal),
x if x == Self::InitrdDebug.as_non_null_terminated_bytes() => Ok(Self::InitrdDebug),
- _ => Err(AvbIOError::NoSuchPartition),
+ _ => Err(avb::IoError::NoSuchPartition),
}
}
}