validate_compressed_buffer binding
This commit is contained in:
parent
25f1f22c86
commit
b38f33531e
@ -46,6 +46,11 @@ extern {
|
||||
compressed_len: size_t,
|
||||
result: *mut size_t,
|
||||
) -> c_int;
|
||||
|
||||
fn snappy_validate_compressed_buffer(
|
||||
compressed: *const c_char,
|
||||
compressed_len: size_t,
|
||||
) -> c_int;
|
||||
}
|
||||
|
||||
/// Errors that can occur during usage of snappy.
|
||||
@ -152,3 +157,9 @@ pub fn decompress_into(input: &[u8], output: &mut [u8]) -> Result<usize, Error>
|
||||
_ => panic!("snappy returned unspecified status"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Validate a compressed buffer. True if valid, false if not.
|
||||
pub fn validate_compressed_buffer(input: &[u8]) -> bool {
|
||||
let status = unsafe { snappy_validate_compressed_buffer(input.as_ptr() as *const c_char, input.len() as size_t )};
|
||||
status == SNAPPY_OK
|
||||
}
|
Loading…
Reference in New Issue
Block a user