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>
impl<R: AsyncRead + Unpin, T: Processable> Driver<R, T>
Sourcepub async fn load_car(
reader: R,
process: fn(Vec<u8>) -> T,
mem_limit_mb: usize,
) -> Result<Driver<R, T>, DriveError>
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.