Skip to main content

sans_io/
sans_io.rs

1// SPDX-FileCopyrightText: 2026 libarchive_oxide contributors
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! Driving the `no_std + alloc` core without giving it an I/O object.
6
7use libarchive_oxide_core::{ArchiveDecoder, DecodeEvent, EndOfInput, Limits, TarDecoder};
8
9fn main() -> Result<(), libarchive_oxide_core::ArchiveError> {
10    let archive = [0_u8; 1024];
11    let mut decoder = TarDecoder::new(Limits::default());
12    let mut position = 0;
13    let mut scratch = [0_u8; 4096];
14
15    loop {
16        let step = decoder.step(&archive[position..], &mut scratch, EndOfInput::End)?;
17        position += step.consumed;
18        if matches!(step.event, DecodeEvent::Done) {
19            return Ok(());
20        }
21    }
22}