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

Read CAR stream from car_input as a single file buffering the block dag in memory

Examples

use rs_car_ipfs::{Cid, single_file::read_single_file_buffer};
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")?;
  let max_buffer = 10_000_000; // 10MB

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