Skip to main content

unityrs_core/codec/
stored.rs

1// Ported from UnityPy 1.25.2 (MIT): UnityPy/helpers/CompressionHelper.py. See THIRD_PARTY_LICENSES.
2//! Compression type 0: [`Stored`], the stored bytes.
3
4use bytes::Bytes;
5
6use super::{BlockCodec, Decoded};
7use crate::budget::DecodeBuf;
8use crate::error::Error;
9
10/// Compression type 0: the stored bytes.
11#[derive(Clone, Copy, Debug, Default)]
12pub struct Stored;
13
14const _: () = crate::send_sync::<Stored>();
15
16impl BlockCodec for Stored {
17    fn decode(&self, input: &Bytes, _: u32, _: &mut DecodeBuf) -> Result<Decoded, Error> {
18        // UnityPy helpers/CompressionHelper.py:239: `lambda cd, _ucs: cd`.
19        Ok(Decoded::Input(0..input.len()))
20    }
21}