1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
mod constants; mod decoder; mod probe; mod reader_core; mod ring_decoder; mod take; pub use decoder::LzfseDecoder; pub use probe::probe; pub use reader_core::ReaderCore; pub use ring_decoder::{LzfseReader, LzfseReaderBytes, LzfseRingDecoder}; pub use take::Take; /// Decode `src` into `dst` returning the number of bytes written into `dst`. /// /// /// This is a convenience method that constructs a temporary [LzfseDecoder] instance and then calls /// [decode_bytes](LzfseDecoder::decode_bytes). For multiple invocations, creating and reusing a /// [LzfseDecoder] instance is more efficient. /// /// # Errors /// /// * [Error](crate::Error) detailing the nature of any errors. /// /// # Aborts /// /// With limited system memory [Vec] may abort when attempting to allocate sufficient memory. /// This issue will be resolved in future releases when [try_reserve()](Vec::try_reserve) is /// stabilized. /// /// # Examples /// /// ``` /// use std::io; /// /// fn main() -> io::Result<()> { /// // "test" string encoded. /// let enc = vec![ /// 0x62, 0x76, 0x78, 0x2d, 0x04, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x62, 0x76, /// 0x78, 0x24, /// ]; /// let mut dec = Vec::default(); /// let n_bytes = lzfse_rust::decode_bytes(&enc, &mut dec)?; /// assert_eq!(n_bytes, 4); /// assert_eq!(dec, b"test"); /// Ok(()) /// } /// ``` pub fn decode_bytes(src: &[u8], dst: &mut Vec<u8>) -> crate::Result<u64> { LzfseDecoder::default().decode_bytes(src, dst) }