Trait iroh_blobs::store::BaoBatchWriter
source · pub trait BaoBatchWriter {
// Required methods
fn write_batch(
&mut self,
size: u64,
batch: Vec<BaoContentItem>
) -> impl Future<Output = Result<()>>;
fn sync(&mut self) -> impl Future<Output = Result<()>>;
}
Expand description
An async batch interface for writing bao content items to a pair of data and outboard.
Details like the chunk group size and the actual storage location are left to the implementation.
Required Methods§
sourcefn write_batch(
&mut self,
size: u64,
batch: Vec<BaoContentItem>
) -> impl Future<Output = Result<()>>
fn write_batch( &mut self, size: u64, batch: Vec<BaoContentItem> ) -> impl Future<Output = Result<()>>
Write a batch of bao content items to the underlying storage.
The batch is guaranteed to be sorted as data is received from the network. So leaves will be sorted by offset, and parents will be sorted by pre order traversal offset. There is no guarantee that they will be consecutive though.
The size is the total size of the blob that the remote side told us.
It is not guaranteed to be correct, but it is guaranteed to be
consistent with all data in the batch. The size therefore represents
an upper bound on the maximum offset of all leaf items.
So it is guaranteed that leaf.offset + leaf.size <= size
for all
leaf items in the batch.
Batches should not become too large. Typically, a batch is just a few parent nodes and a leaf.
Batch is a vec so it can be moved into a task, which is unfortunately necessary in typical io code.
Object Safety§
Implementations on Foreign Types§
source§impl<W: BaoBatchWriter> BaoBatchWriter for &mut W
impl<W: BaoBatchWriter> BaoBatchWriter for &mut W
Implement BaoBatchWriter for mutable references