Vehicle

Struct Vehicle 

Source
pub struct Vehicle<SE, S, T, P, PE>
where S: Stream<Item = Result<(Cid, Vec<u8>), SE>>, P: Fn(&[u8]) -> Result<T, PE>, PE: Error,
{ /* private fields */ }
Expand description

The core driver between the block stream and MST walker

Implementations§

Source§

impl<SE, S, T: Clone, P, PE> Vehicle<SE, S, T, P, PE>
where SE: Error + 'static, S: Stream<Item = Result<(Cid, Vec<u8>), SE>> + Unpin, P: Fn(&[u8]) -> Result<T, PE>, PE: Error,

Source

pub async fn init( root: Cid, block_stream: S, process: P, ) -> Result<(Commit, Self), DriveError<PE>>

Set up the stream

This will eagerly consume blocks until the Commit object is found. Usually the it’s the first block, but there is no guarantee.

§Parameters

root: CID of the commit object that is the root of the MST

block_stream: Input stream of raw CAR blocks

process: record-transforming callback:

For tasks where records can be quickly processed into a smaller useful representation, you can do that eagerly as blocks come in by passing the processor as a callback here. This can reduce overall memory usage.

Source

pub async fn next_record( &mut self, ) -> Result<Option<(String, T)>, DriveError<PE>>

Manually step through the record outputs

Source

pub fn stream(self) -> impl Stream<Item = Result<(String, T), DriveError<PE>>>

Convert to a futures::stream of record outputs

Auto Trait Implementations§

§

impl<SE, S, T, P, PE> Freeze for Vehicle<SE, S, T, P, PE>
where S: Freeze, P: Freeze,

§

impl<SE, S, T, P, PE> RefUnwindSafe for Vehicle<SE, S, T, P, PE>

§

impl<SE, S, T, P, PE> Send for Vehicle<SE, S, T, P, PE>
where S: Send, P: Send, T: Send, PE: Send,

§

impl<SE, S, T, P, PE> Sync for Vehicle<SE, S, T, P, PE>
where S: Sync, P: Sync, T: Sync, PE: Sync,

§

impl<SE, S, T, P, PE> Unpin for Vehicle<SE, S, T, P, PE>
where S: Unpin, P: Unpin, T: Unpin, PE: Unpin,

§

impl<SE, S, T, P, PE> UnwindSafe for Vehicle<SE, S, T, P, PE>

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.