Skip to main content

ObjStm

Struct ObjStm 

Source
pub struct ObjStm { /* private fields */ }
Expand description

A decoded object stream with its header parsed once.

The header is 2*n integers — pairs of object number and byte offset — followed by the object bodies; offsets are relative to first, where the first body begins. Parsing the header up front turns per-object extraction from an O(n) rescan (O(n^2) across a whole stream) into a direct lookup.

Implementations§

Source§

impl ObjStm

Source

pub fn parse(data: Vec<u8>, n: usize, first: usize) -> Result<ObjStm>

Decodes the header of an object stream, keeping the decompressed bytes for later per-object parsing.

Source

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

Parses the object at index from the already-decoded bytes.

Source

pub fn object_spanned(&self, index: u32) -> Result<(Object, (usize, usize))>

Parses the object at index, also reporting its byte range within the decoded stream data.

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> 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, 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.