pub struct Xbc1 {
pub compression_type: CompressionType,
pub decompressed_size: u32,
pub compressed_size: u32,
pub decompressed_hash: u32,
pub name: String,
pub compressed_stream: Vec<u8>,
}
Expand description
A compressed container for a single file or stream.
Fields§
§compression_type: CompressionType
The compression type for compressed_stream.
decompressed_size: u32
The number of bytes in Self::decompress.
compressed_size: u32
The number of bytes in compressed_stream.
decompressed_hash: u32
Hash of the original decompressed bytes for compressed_stream using hash_crc.
name: String
The name for this archive.
This is often the name of the original file like 3d4f4c6_middle.witx
.
compressed_stream: Vec<u8>
A compressed stream encoded based on compression_type. The decompressed stream will have size decompressed_size.
Implementations§
Source§impl Xbc1
impl Xbc1
Sourcepub fn new<T>(
name: String,
data: &T,
compression_type: CompressionType,
) -> Result<Self, CreateXbc1Error>
pub fn new<T>( name: String, data: &T, compression_type: CompressionType, ) -> Result<Self, CreateXbc1Error>
Write and compress data
.
Use CompressionType::Zlib for best compatibility.
Sourcepub fn from_decompressed(
name: String,
decompressed: &[u8],
compression_type: CompressionType,
) -> Result<Self, CreateXbc1Error>
pub fn from_decompressed( name: String, decompressed: &[u8], compression_type: CompressionType, ) -> Result<Self, CreateXbc1Error>
Compress the data in decompressed
.
Use CompressionType::Zlib for best compatibility.
Sourcepub fn decompress(&self) -> Result<Vec<u8>, DecompressStreamError>
pub fn decompress(&self) -> Result<Vec<u8>, DecompressStreamError>
Decompresses the data in compressed_stream.
Unlike Self::decompress_check_hash, this skips a slow hashing check for the decompressed data.
Sourcepub fn decompress_check_hash(&self) -> Result<Vec<u8>, DecompressStreamError>
pub fn decompress_check_hash(&self) -> Result<Vec<u8>, DecompressStreamError>
Similar to Self::decompress but returns an error if the hash of the decompressed data does not match.
Source§impl Xbc1
impl Xbc1
Source§impl Xbc1
impl Xbc1
pub fn read<R: Read + Seek>(reader: &mut R) -> BinResult<Self>
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, ReadFileError>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, ReadFileError>
Read from path
using a fully buffered reader for performance.
Sourcepub fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> BinResult<Self>
pub fn from_bytes<T: AsRef<[u8]>>(bytes: T) -> BinResult<Self>
Read from bytes
using a fully buffered reader for performance.
Trait Implementations§
Source§impl BinRead for Xbc1
impl BinRead for Xbc1
Source§fn read_options<R: Read + Seek>(
__binrw_generated_var_reader: &mut R,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<Self>
Source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T
from the reader assuming native-endian byte order. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self
from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§impl BinWrite for Xbc1
impl BinWrite for Xbc1
Source§fn write_options<W: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<()>
Source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming little-endian byte order. Read moreSource§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming native-endian byte order. Read moreSource§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self
to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl WriteMagic for Xbc1
impl WriteMagic for Xbc1
Source§impl Xc3Write for Xbc1
impl Xc3Write for Xbc1
Source§type Offsets<'a> = ()
type Offsets<'a> = ()
Source§fn xc3_write<W: Write + Seek>(
&self,
writer: &mut W,
endian: Endian,
) -> Xc3Result<Self::Offsets<'_>>
fn xc3_write<W: Write + Seek>( &self, writer: &mut W, endian: Endian, ) -> Xc3Result<Self::Offsets<'_>>
Source§fn should_write(&self) -> Option<bool>
fn should_write(&self) -> Option<bool>
Some(_)
if the offset should be updated and
Some(true)
if the data should also be written.
Defaults to Some(true)
.impl StructuralPartialEq for Xbc1
Auto Trait Implementations§
impl Freeze for Xbc1
impl RefUnwindSafe for Xbc1
impl Send for Xbc1
impl Sync for Xbc1
impl Unpin for Xbc1
impl UnwindSafe for Xbc1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more