| 1 | #![allow(unsafe_code)] |
| 2 | |
| 3 | use superrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/::superrust-analyzer cargo lzzzz 2.0.0 lz4_hc/::bindingrust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/; |
| 4 | |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 6 | cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#, |
| 7 | opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, |
| 8 | osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::rawrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/::{c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, c_voidrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_void#}, |
| 9 | }; |
| 10 | |
| 11 | pub const fn size_of_staterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/size_of_state().() -> usize { |
| 12 | bindingrust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/::LZ4_STREAMHCSIZErust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/LZ4_STREAMHCSIZE. |
| 13 | } |
| 14 | |
| 15 | pub fn compress_ext_staterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/compress_ext_state().( |
| 16 | state: &mut [u8], |
| 17 | src: &[u8], |
| 18 | dst: *mut u8, |
| 19 | dst_len: usize, |
| 20 | compression_level: i32, |
| 21 | ) -> usize { |
| 22 | unsafe { |
| 23 | bindingrust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/::LZ4_compress_HC_extStateHCrust-analyzer cargo lzzzz 2.0.0 LZ4_compress_HC_extStateHC().( |
| 24 | state.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut c_voidrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_void#, |
| 25 | src.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *const c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 26 | dst as *mut c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 27 | src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 28 | dst_len as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 29 | compression_level as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 30 | ) as usize |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | pub fn compress_ext_state_fast_resetrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/compress_ext_state_fast_reset().( |
| 35 | state: &mut [u8], |
| 36 | src: &[u8], |
| 37 | dst: *mut u8, |
| 38 | dst_len: usize, |
| 39 | compression_level: i32, |
| 40 | ) -> usize { |
| 41 | unsafe { |
| 42 | bindingrust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/::LZ4_compress_HC_extStateHC_fastResetrust-analyzer cargo lzzzz 2.0.0 LZ4_compress_HC_extStateHC_fastReset().( |
| 43 | state.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut c_voidrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_void#, |
| 44 | src.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *const c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 45 | dst as *mut c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 46 | src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 47 | dst_len as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 48 | compression_level as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 49 | ) as usize |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | pub fn compress_dest_sizerust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/compress_dest_size().( |
| 54 | state: &mut [u8], |
| 55 | src: &[u8], |
| 56 | dst: &mut [u8], |
| 57 | compression_level: i32, |
| 58 | ) -> (usize, usize) { |
| 59 | let mut src_len = src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as i32; |
| 60 | let dst_len = unsafe { |
| 61 | bindingrust-analyzer cargo lzzzz 2.0.0 lz4_hc/binding/::LZ4_compress_HC_destSizerust-analyzer cargo lzzzz 2.0.0 LZ4_compress_HC_destSize().( |
| 62 | state.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut c_voidrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_void#, |
| 63 | src.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as *const c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 64 | dst.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut c_charrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_char#, |
| 65 | &mut src_len as *mut c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 66 | dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 67 | compression_level as c_intrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_int#, |
| 68 | ) as usize |
| 69 | }; |
| 70 | (src_len as usize, dst_len) |
| 71 | } |
| 72 | |
| 73 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 74 | pub struct ExtStaterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState#(RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]>>); |
| 75 | |
| 76 | impl ExtStaterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState# { |
| 77 | fn newrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState]new().() -> Selfrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState] { |
| 78 | let size = size_of_staterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/size_of_state().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 79 | Selfrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState](RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; size].into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().())) |
| 80 | } |
| 81 | |
| 82 | pub fn withrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState]with().<F, R>(f: F) -> R |
| 83 | where |
| 84 | F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(&Selfrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState], bool) -> R, |
| 85 | { |
| 86 | EXT_STATErust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/EXT_STATE..withrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/impl#[`LocalKey<T>`]with().(|state| { |
| 87 | let reset = { |
| 88 | let mut state = state.borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 89 | let last = state.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1; |
| 90 | if state[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().last]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 { |
| 91 | state[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().last]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 1; |
| 92 | false |
| 93 | } else { |
| 94 | true |
| 95 | } |
| 96 | }; |
| 97 | |
| 98 | (f)(state, reset) |
| 99 | }) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for ExtStaterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState# { |
| 104 | type Targetrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState][Deref]Target# = RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]>>; |
| 105 | |
| 106 | fn derefrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState][Deref]deref().(&self) -> &Selfrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# { |
| 107 | &self.0rust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState#0. |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | thread_localrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/local/thread_local!!(static EXT_STATErust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/EXT_STATE.: ExtStaterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState# = ExtStaterust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/ExtState#::newrust-analyzer cargo lzzzz 2.0.0 lz4_hc/block/api/impl#[ExtState]new().()); |