1#![cfg_attr(not(feature = "std"), no_std)]
2#![allow(bad_style)]
3
4extern crate libc;
5
6#[cfg(feature = "crc32fast")]
7extern crate crc32fast;
8
9#[cfg(test)]
10extern crate quickcheck;
11#[cfg(test)]
12extern crate quickcheck_macros;
13
14pub mod bps;
15pub mod ips;
16pub mod ups;
17
18mod crc32;
19#[cfg(test)]
20mod test_utils;
21
22#[repr(C)]
27#[derive(Copy, Clone, Debug)]
28pub struct mem {
29 pub ptr: *mut u8,
30 pub len: libc::size_t,
31}
32
33impl mem {
34 pub fn new(ptr: *mut u8, len: libc::size_t) -> Self {
35 Self { ptr, len }
36 }
37}
38
39impl Default for mem {
40 fn default() -> Self {
41 Self::new(core::ptr::null_mut(), 0)
42 }
43}
44
45impl AsRef<[u8]> for mem {
46 fn as_ref(&self) -> &[u8] {
47 unsafe {
48 core::slice::from_raw_parts(self.ptr as *const _, self.len)
49 }
50 }
51}