Driver

Enum Driver 

Source
pub enum Driver<R: AsyncRead + Unpin, T: Processable> {
    Memory(Commit, MemDriver<T>),
    Disk(NeedDisk<R, T>),
}
Expand description

Read a CAR file, buffering blocks in memory or to disk

Variants§

§

Memory(Commit, MemDriver<T>)

All blocks fit within the memory limit

You probably want to check the commit’s signature. You can go ahead and walk the MST right away.

§

Disk(NeedDisk<R, T>)

Blocks exceed the memory limit

You’ll need to provide a disk storage to continue. The commit will be returned and can be validated only once all blocks are loaded.

Implementations§

Source§

impl<R: AsyncRead + Unpin, T: Processable> Driver<R, T>

Source

pub async fn load_car( reader: R, process: fn(Vec<u8>) -> T, mem_limit_mb: usize, ) -> Result<Driver<R, T>, DriveError>

Begin processing an atproto MST from a CAR file

Blocks will be loaded, processed, and buffered in memory. If the entire processed size is under the mem_limit_mb limit, a Driver::Memory will be returned along with a Commit ready for validation.

If the mem_limit_mb limit is reached before loading all blocks, the partial state will be returned as Driver::Disk(needed), which can be resumed by providing a SqliteStorage for on-disk block storage.

Auto Trait Implementations§

§

impl<R, T> Freeze for Driver<R, T>
where R: Freeze,

§

impl<R, T> RefUnwindSafe for Driver<R, T>

§

impl<R, T> Send for Driver<R, T>
where R: Send, T: Send,

§

impl<R, T> Sync for Driver<R, T>
where R: Sync, T: Sync,

§

impl<R, T> Unpin for Driver<R, T>
where T: Unpin,

§

impl<R, T> UnwindSafe for Driver<R, T>
where R: UnwindSafe, T: 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.