mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 18:40:18 +00:00
chore(eficore): decouple the shim support from the image load callsites
This commit is contained in:
25
crates/eficore/src/loader/source.rs
Normal file
25
crates/eficore/src/loader/source.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use crate::path::ResolvedPath;
|
||||
use crate::shim::ShimInput;
|
||||
|
||||
/// Represents a source of an EFI image.
|
||||
pub enum ImageSource<'source> {
|
||||
/// The image is located at the specified path that has been resolved.
|
||||
ResolvedPath(&'source ResolvedPath),
|
||||
/// The image is located in a buffer.
|
||||
DataBuffer {
|
||||
/// Optional path to the image.
|
||||
path: Option<&'source ResolvedPath>,
|
||||
/// Buffer containing the image.
|
||||
buffer: &'source [u8],
|
||||
},
|
||||
}
|
||||
|
||||
/// Implement conversion from `ImageSource` to `ShimInput`, which is used by the shim support code.
|
||||
impl<'source> From<ImageSource<'source>> for ShimInput<'source> {
|
||||
fn from(value: ImageSource<'source>) -> Self {
|
||||
match value {
|
||||
ImageSource::ResolvedPath(path) => ShimInput::ResolvedPath(path),
|
||||
ImageSource::DataBuffer { path, buffer } => ShimInput::DataBuffer(path, buffer),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user