use super::{DESCRIPTOR, container::ApfsContainer};
use crate::{ByteSourceHandle, DataSource, Driver, OpenOptions, Result};
#[derive(Debug, Default, Clone, Copy)]
pub struct ApfsDriver;
impl ApfsDriver {
pub const fn new() -> Self {
Self
}
pub fn open(source: ByteSourceHandle) -> Result<ApfsContainer> {
ApfsContainer::open(source)
}
}
impl Driver for ApfsDriver {
fn descriptor(&self) -> crate::FormatDescriptor {
DESCRIPTOR
}
fn open(
&self, source: ByteSourceHandle, options: OpenOptions<'_>,
) -> Result<Box<dyn DataSource>> {
let container = ApfsContainer::open(source)?;
if let Some(selector) = options.view {
return container.open_view(&selector, options);
}
Ok(Box::new(container))
}
}