6XB4RDRQIINYARVQUO3U3ZG7652UIUXBUF33U7JEJ7ASRI47EKHAC
L7S3YSSMT6JCK4A7MCXZDMDEFBP7XJITHFRDMDKJ5L2RDVHI4AHAC
HEFGMMUMJ2GGJGF2BEKF7EUL24AO53WJTXKBJSEGT64AV3Y4TBZQC
K6L5F26WJMIYPP3Y3CBBUYMAK7C5SVR7NYFNU45NGU5NMDCSJJIQC
IH334Q5ACWE4TNQYYOOF6GWV6CRXOEM6542NVNPA6HRIZ3CBFKEAC
IB4L4N5M765IYALNZENJRKOGUPBRK2AMAB6IRNWPDCKNKKRMOB5AC
HA3ODU4GEQ4X55UDTY3QZUTD557DHTIHH2B5CSMY7YNHOBYQARBQC
SZHL3TSDHAQ3C4JKQRNYFDWOSXURPIN72HKTXQRY7YCABQDJE5FQC
GKNZUJV6XUPOHKZEOOPOWMCYRBTMR36WTLOBEIPWZ55DX6SRUAVAC
UPRY2FELRWZCL5FGUS3EKS2RXEY7D2FGXYGLJWDNJT23PHITRWMAC
HELRYMZKHZW4S2IEYXA4IE7VOYYL7FH6TVHGFHJ4J3KRBBLHPQPAC
Error::PrefixUnknown(p) => write!(fmt, "Prefix unknown {}", p),
Error::Corruption(ref s) => write!(fmt, "Corruption detected {}.", s),
Error::PrefixUnknown(p) => write!(fmt, "Unknown frame descriptor {}", p),
Error::Corruption(ref s) => write!(fmt, "Corrupted block detected {}.", s),
pub fn decompress(&mut self, out: &mut [u8], len: usize, offset: u64) -> Result<usize, Error> {
pub fn decompress(&mut self, out: &mut [u8], len: u64, offset: u64) -> Result<usize, Error> {
let eos = self.seek_table.entries[self.seek_table.entries.len() - 1].d_offset;
let len = if offset + len > eos {
eos - offset
} else {
len
};
unsafe { ZSTD_resetDStream(self.dstream) };
unsafe {
let r = ZSTD_DCtx_reset(self.dstream, ZSTD_reset_session_only);
if ZSTD_isError(r) != 0 {
return Err(Error::ZSTD(r));
}
}
if let Some(size) = &self.inner_buf_size {
if src_bytes_read > *size {
return Err(Error::SeekableIo);
}
}
self.decompressed_offset += (out_tmp.pos - prev_out_pos) as u64;
let forward_progress = (out_tmp.pos - prev_out_pos) as u64;
if forward_progress == 0 {
no_output_progress_c += 1;
if no_output_progress_c > SEEKABLE_NO_OUTPUT_PROGRESS_MAX {
return Err(Error::SeekableIo);
}
} else {
no_output_progress_c = 0;
}
self.decompressed_offset += forward_progress;
src_bytes_read += self.inn.pos - prev_in_pos;
/// Offset of the frame in the compressed data.
pub fn get_frame_compressed_offset(&self, frame_index: usize) -> Result<usize, Error> {
#[inline(always)]
fn get_frame(&'_ self, frame_index: usize) -> Result<&'_ SeekEntry, Error> {
pub fn get_frame_compressed_size(&self, frame_index: usize) -> Result<usize, Error> {
let max_frames = self.get_num_frames();
if frame_index >= max_frames {
Err(Error::FIndexTooLarge(frame_index, max_frames))
} else {
Ok(self.seek_table.entries[frame_index + 1].c_offset
- self.seek_table.entries[frame_index].c_offset)
}
pub fn get_frame_compressed_size(&self, frame_index: usize) -> Result<u64, Error> {
let entry = self.get_frame(frame_index)?;
Ok(self.seek_table.entries[frame_index + 1].c_offset - entry.c_offset)
pub fn get_frame_decompressed_offset(&self, frame_index: usize) -> Result<usize, Error> {
let max_frames = self.get_num_frames();
if frame_index >= max_frames {
Err(Error::FIndexTooLarge(frame_index, max_frames))
} else {
Ok(self.seek_table.entries[frame_index].d_offset)
}
pub fn get_frame_decompressed_offset(&self, frame_index: usize) -> Result<u64, Error> {
Ok(self.get_frame(frame_index)?.d_offset)
pub fn get_frame_decompressed_size(&self, frame_index: usize) -> Result<usize, Error> {
let max_frames = self.get_num_frames();
if frame_index >= max_frames {
Err(Error::FIndexTooLarge(frame_index, max_frames))
} else {
let r = self.seek_table.entries[frame_index + 1].d_offset
- self.seek_table.entries[frame_index].d_offset;
Ok(r)
}
pub fn get_frame_decompressed_size(&self, frame_index: usize) -> Result<u64, Error> {
let entry = self.get_frame(frame_index)?;
Ok(self.seek_table.entries[frame_index + 1].d_offset - entry.d_offset)