Skip to main content

LumenFile

Struct LumenFile 

Source
pub struct LumenFile<'a> { /* private fields */ }
Expand description

An open LUMEN file.

Implementations§

Source§

impl<'a> LumenFile<'a>

Source

pub fn open_unvalidated(buf: &'a [u8]) -> Result<LumenFile<'a>>

Open without checking the whole of section 11 first.

LumenFile::open runs every check of section 11 before it returns, and one of them walks each slice’s stream. A caller that wants a single layer, a layer preview for instance, pays for that walk without asking. This parses the container and its chunks and checks nothing: it leaves the streams to LumenFile::layer, which reports a malformed one when it reaches it.

Source

pub fn open(buf: &'a [u8], level: Level) -> Result<LumenFile<'a>>

Open a plaintext file, validating it against level.

Source

pub fn open_with_key( buf: &'a [u8], level: Level, key: SessionKey, ) -> Result<LumenFile<'a>>

Open a file whose session key is already known.

Source

pub fn open_with_password( buf: &'a [u8], level: Level, password: &str, ) -> Result<LumenFile<'a>>

Open a password-protected file.

Source

pub fn open_with_machine_key( buf: &'a [u8], level: Level, private_key: &[u8; 32], ) -> Result<LumenFile<'a>>

Open a machine-bound file with the recipient’s X25519 private key.

Source

pub fn recover_password(&self, password: &str) -> Result<SessionKey>

Recover the session key from a password, without reopening.

Source

pub fn recover_machine_key(&self, private_key: &[u8; 32]) -> Result<SessionKey>

Recover the session key from a recipient private key, without reopening.

Source

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

The file’s bytes.

Source

pub fn header(&self) -> &FileHeader

The fixed file header.

Source

pub fn directory(&self) -> &Directory

The chunk directory.

Source

pub fn head(&self) -> &Head

The HEAD chunk.

Source

pub fn meta(&self) -> &Meta

The META chunk.

Source

pub fn profile(&self) -> Option<&Profile>

The PROF chunk, if present. A file carries at most one.

Source

pub fn meta_sectors(&self) -> &[Sector]

Every sector META defines, in the order it lists them.

Sector 0 is implicit and has no entry here.

Source

pub fn previews(&self) -> &[Preview]

Every PREV chunk, in file order.

Source

pub fn extensions(&self) -> &[Extension]

Every EXTD chunk whose frame could be read, in file order.

Source

pub fn dictionary(&self) -> Option<&ZstdDictionary>

The ZDIC chunk, if present.

Source

pub fn layer_hashes(&self) -> Option<&LayerHashes>

The LHAS chunk, if present.

Source

pub fn layer_table(&self) -> &LayerTable

The LTBL chunk.

Source

pub fn layr_chunks(&self) -> &[LayrChunk]

Every LAYR chunk, in directory order.

Source

pub fn voxl(&self) -> Option<&[u8]>

The VOXL payload, if present, verbatim.

Source

pub fn auth(&self) -> Option<&Auth>

The AUTH chunk, if present.

Source

pub fn layer_count(&self) -> u32

The layer count.

Source

pub fn total_pixels(&self) -> u32

Pixels in one layer mask.

Source

pub fn multi_sector(&self) -> bool

Whether the file declares sector-based layer encoding, i.e. whether some layer carries more than one sector (head.multi_sector_flag).

This is informational: which sectors a layer carries is read from its LTBL entries, not from this flag.

Source

pub fn level(&self) -> Level

Whether the validation level this file was opened at is strict.

Source

pub fn is_unlocked(&self) -> bool

Whether the file has a session key available.

Source

pub fn layr_chunk_data(&self, index: u32) -> Result<Vec<u8>>

The decompressed, decrypted output of the LAYR chunk at directory index index: the concatenation of every slice the table places in it.

Source

pub fn layer(&self, index: u32) -> Result<DecodedLayer>

The decoded mask of layer index as a single-material reader prints it.

That reader reads the layer’s first entry - sector 0’s, which every layer with data has - and skips the rest, so this is sector 0’s mask and not the union of every sector’s. A layer whose first entry carries no data is empty here even when a later sector holds data; LumenFile::is_single_material_complete reports that case, and LumenFile::layer_sectors reaches the other sectors.

Source

pub fn layer_sectors(&self, index: u32) -> Result<Vec<DecodedSector>>

Every sector’s decoded mask on layer index, in ascending sector_id.

A sector with no data on this layer has no mask and is not reported.

Source

pub fn is_single_material_complete(&self) -> bool

Whether a single-material reader would print every layer faithfully.

False when any layer carries data in a sector other than 0, which is content such a reader never reads and would drop silently: it must report the file incomplete rather than complete (section 7.2).

Source

pub fn timing_for(&self, layer: u32, sector_id: u32) -> Result<Resolved>

Resolve one (layer, sector)’s timing.

The returned values already carry the sector’s META.sectors entry, the bottom and transition blend with the counts that sector carries or inherits, and the (layer, sector)’s own LROV payload. Overrides are not opt-in ([spec/08-print-control.md] section 4.5): a reader that does not apply them must refuse a file that carries an LROV chunk, because printing the layer at META’s exposure instead of its override fails quietly. This method is therefore the only supported way to read a layer’s timing.

Source

pub fn verify_layer(&self, index: u32) -> Result<()>

Verify layer index against the LHAS leaf table and Merkle path.

Source

pub fn verify_all(&self) -> Result<()>

Verify every layer and the Merkle root.

Trait Implementations§

Source§

impl<'a> Debug for LumenFile<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for LumenFile<'a>

§

impl<'a> !RefUnwindSafe for LumenFile<'a>

§

impl<'a> !Sync for LumenFile<'a>

§

impl<'a> Send for LumenFile<'a>

§

impl<'a> Unpin for LumenFile<'a>

§

impl<'a> UnsafeUnpin for LumenFile<'a>

§

impl<'a> UnwindSafe for LumenFile<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V