-
-
Save rust-play/9c506790bbce761c59c8b7419fd293be to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn ready_next_slice_from_idat(&mut self) -> Result<(), ZlibError> { | |
debug_assert!(self.spare_slice.is_empty()); | |
match self.idat_iter.next() { | |
Some(Ok(sli)) => Ok(self.spare_slice = sli), | |
otherwise => Err(ZlibError::UnexpectedEndOfStream), | |
} | |
} | |
fn ready_next_byte(&mut self) -> Result<(), ZlibError> { | |
debug_assert!(self.spare_bits_count + 8 < 32); | |
if self.spare_slice.is_empty() { | |
self.ready_next_slice_from_idat()? | |
} | |
debug_assert!(!self.spare_slice.is_empty()); | |
self.spare_bits |= u32::from(self.spare_slice[0]) << self.spare_bits_count; | |
self.spare_bits_count += 8; | |
#[cfg(not(feature = "png_skip_adler_checks"))] | |
{ | |
self.adler = update_adler32(self.adler, &self.spare_slice[0..1]); | |
} | |
Ok(self.spare_slice = &self.spare_slice[1..]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment