Skip to main content

PfscImage

Struct PfscImage 

Source
pub struct PfscImage<I: Image> { /* private fields */ }
Expand description

A decompressing Image adapter for PFSC-compressed files.

Each PFSC block is independently compressed, so read_at at any offset only needs to decompress one block (or two if straddling a boundary). All state is local to each call — no shared mutable state, naturally thread-safe.

Created via PfscImage::open().

§Example

use orbis_pfs::image::Image;
use orbis_pfs::pfsc::PfscImage;

let pfsc = PfscImage::open(source)?;
let pfs = orbis_pfs::open_image(pfsc)?;

Implementations§

Source§

impl<I: Image> PfscImage<I>

Source

pub fn open(source: I) -> Result<Self, OpenError>

Opens a PFSC-compressed image from an underlying Image source.

Reads the PFSC header and block offset table at construction time.

Source

pub fn decompressed_len(&self) -> u64

Returns the decompressed size of the file.

Trait Implementations§

Source§

impl<I: Image> Debug for PfscImage<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: Image> Image for PfscImage<I>

Source§

fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<usize>

Reads bytes from the image at the given offset into buf. Read more
Source§

fn len(&self) -> u64

Returns the total length of the image in bytes.
Source§

fn read_exact_at(&self, offset: u64, output_buf: &mut [u8]) -> Result<()>

Reads exactly buf.len() bytes from image at offset. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the image is empty.

Auto Trait Implementations§

§

impl<I> Freeze for PfscImage<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for PfscImage<I>
where I: RefUnwindSafe,

§

impl<I> Send for PfscImage<I>

§

impl<I> Sync for PfscImage<I>

§

impl<I> Unpin for PfscImage<I>
where I: Unpin,

§

impl<I> UnwindSafe for PfscImage<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.