Skip to content

Commit d2ab618

Browse files
committed
expose set_dictionary
1 parent c858bb9 commit d2ab618

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

zlib-rs/src/stable.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ impl Inflate {
144144
ReturnCode::VersionError => unreachable!("the rust API does not use the version"),
145145
}
146146
}
147+
148+
pub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<u32, InflateError> {
149+
match crate::inflate::set_dictionary(&mut self.0, dictionary) {
150+
ReturnCode::Ok => Ok(self.0.adler as u32),
151+
ReturnCode::StreamError => Err(InflateError::StreamError),
152+
ReturnCode::DataError => Err(InflateError::DataError),
153+
other => unreachable!("set_dictionary does not return {other:?}"),
154+
}
155+
}
147156
}
148157

149158
impl Drop for Inflate {
@@ -259,6 +268,17 @@ impl Deflate {
259268

260269
crate::deflate::deflate(&mut self.0, flush).into()
261270
}
271+
272+
/// Specifies the compression dictionary to use.
273+
///
274+
/// Returns the Adler-32 checksum of the dictionary.
275+
pub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<u32, DeflateError> {
276+
match crate::deflate::set_dictionary(&mut self.0, dictionary) {
277+
ReturnCode::Ok => Ok(self.0.adler as u32),
278+
ReturnCode::StreamError => Err(DeflateError::StreamError),
279+
other => unreachable!("set_dictionary does not return {other:?}"),
280+
}
281+
}
262282
}
263283

264284
impl Drop for Deflate {

0 commit comments

Comments
 (0)