pub fn open_slice<'a>(
data: &'a [u8],
ekpfs: Option<&[u8]>,
) -> Result<Arc<Pfs<'a>>, OpenSliceError>Expand description
Opens a PFS image for reading from a byte slice.
This is the primary entry point when the image data is already in memory.
For unencrypted images, this avoids intermediate buffer allocations during
header and inode parsing by reading directly from the slice, and enables
zero-copy file access via file::File::as_slice().
§Arguments
data- The PFS image data as a byte sliceekpfs- The EKPFS key for encrypted images, orNonefor unencrypted images
§Returns
Returns a thread-safe, reference-counted Pfs handle on success.
§Errors
Returns an OpenSliceError if:
- The image header is invalid
- The image is encrypted but no key is provided
- The block structure is invalid
§Example
let data = std::fs::read("image.pfs")?;
let pfs = orbis_pfs::open_slice(&data, None)?;
println!("Opened PFS with {} inodes", pfs.inode_count());