Skip to main content

Container

Struct Container 

Source
pub struct Container {
    pub declared_size: u64,
    pub first_chunk: u64,
    pub head: Option<Head>,
    pub chunks: Vec<Chunk>,
    pub trailing: usize,
    /* private fields */
}
Expand description

A parsed .clip container. Holds the original bytes.

Fields§

§declared_size: u64

File size the header declares.

§first_chunk: u64

Offset of the first chunk the header declares (24).

§head: Option<Head>

The CHNKHead contents, if the file has one.

§chunks: Vec<Chunk>

Every chunk, in file order.

§trailing: usize

Bytes after the footer chunk (none in CSP files).

Implementations§

Source§

impl Container

Source

pub fn read(path: impl AsRef<Path>) -> Result<Self>

Reads and parses a file.

Source

pub fn sniff(data: &[u8]) -> bool

Whether data starts like a .clip container.

Source

pub fn parse(data: Vec<u8>) -> Result<Self>

Parses the bytes of a .clip; fails on a truncated or malformed container.

Source

pub fn bytes(&self) -> &[u8] ⓘ

The bytes as read.

Source

pub fn into_bytes(self) -> Vec<u8> ⓘ

The bytes as read, by value.

Source

pub fn body(&self, chunk: &Chunk) -> &[u8] ⓘ

The body of a chunk.

Source

pub fn sqlite(&self) -> Result<&[u8]>

The embedded SQLite database image.

Source

pub fn sqlite_chunk(&self) -> Option<&Chunk>

The database chunk.

Source

pub fn external_chunks(&self) -> impl Iterator<Item = &Chunk>

External chunks in file order.

Source

pub fn external_chunk(&self, id: &str) -> Option<&Chunk>

The external chunk with this id.

Source

pub fn external(&self, id: &str) -> Option<&[u8]>

Payload of an external chunk (after its id). None when the id is not stored: CSP keeps ids of offscreens it will build on opening.

Source

pub fn external_ids(&self) -> impl Iterator<Item = &str>

Ids of the external chunks, in file order.

Source

pub fn findings(&self) -> Vec<String>

Structural problems that do not stop reading (empty when CSP-like).

Source

pub fn reassemble(&self) -> Vec<u8> ⓘ

Rebuild the file from its parsed parts (used to prove the parser misses nothing: the result must equal Container::bytes).

Trait Implementations§

Source§

impl Clone for Container

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Container

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.