pub async fn read_single_file_seek<R: AsyncRead + Send + Unpin, W: AsyncSeek + AsyncRead + AsyncWrite + Unpin>(
    car_input: &mut R,
    out: &mut W,
    root_cid: Option<&Cid>
) -> Result<(), ReadSingleFileError>
Expand description

Read CAR stream from car_input as a single file without buffering the block dag in memory, reading de-duplicated blocks from out.

Examples

use rs_car_ipfs::{Cid, single_file::read_single_file_seek};
use futures::io::Cursor;

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
  let mut input = async_std::fs::File::open("tests/example.car").await?;
  let mut out = async_std::fs::File::create("tests/data/helloworld.txt").await?;
  let root_cid = Cid::try_from("QmUU2HcUBVSXkfWPUc3WUSeCMrWWeEJTuAgR9uyWBhh9Nf")?;

  read_single_file_seek(&mut input, &mut out, Some(&root_cid)).await?;
  Ok(())
}