Skip to content

Commit

Permalink
Merge pull request #20 from AlyoshaVasilieva/impl
Browse files Browse the repository at this point in the history
Add Debug derives
  • Loading branch information
pmarks committed Mar 5, 2022
2 parents d7ca65b + 5a24f8d commit 0a1d269
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
16 changes: 11 additions & 5 deletions lz4-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ use std::os::raw::{c_void, c_char, c_uint, c_int};
#[allow(non_camel_case_types)]
type size_t = usize;

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct LZ4FCompressionContext(pub *mut c_void);
unsafe impl Send for LZ4FCompressionContext {}

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct LZ4FDecompressionContext(pub *mut c_void);
unsafe impl Send for LZ4FDecompressionContext {}

pub type LZ4FErrorCode = size_t;

#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(u32)]
pub enum BlockSize {
Default = 0, // Default - 64KB
Expand All @@ -60,20 +60,21 @@ impl BlockSize {
}
}

#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(u32)]
pub enum BlockMode {
Linked = 0,
Independent,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
#[repr(u32)]
pub enum ContentChecksum {
NoChecksum = 0,
ChecksumEnabled,
}

#[derive(Debug)]
#[repr(C)]
pub struct LZ4FFrameInfo {
pub block_size_id: BlockSize,
Expand All @@ -82,6 +83,7 @@ pub struct LZ4FFrameInfo {
pub reserved: [c_uint; 5],
}

#[derive(Debug)]
#[repr(C)]
pub struct LZ4FPreferences {
pub frame_info: LZ4FFrameInfo,
Expand All @@ -90,6 +92,7 @@ pub struct LZ4FPreferences {
pub reserved: [c_uint; 4],
}

#[derive(Debug)]
#[repr(C)]
pub struct LZ4FCompressOptions {
pub stable_src: c_uint, /* 1 == src content will remain available on future calls
Expand All @@ -98,16 +101,19 @@ pub struct LZ4FCompressOptions {
pub reserved: [c_uint; 3],
}

#[derive(Debug)]
#[repr(C)]
pub struct LZ4FDecompressOptions {
pub stable_dst: c_uint, /* guarantee that decompressed data will still be there on next
* function calls (avoid storage into tmp buffers) */
pub reserved: [c_uint; 3],
}

#[derive(Debug)]
#[repr(C)]
pub struct LZ4StreamEncode(c_void);

#[derive(Debug)]
#[repr(C)]
pub struct LZ4StreamDecode(c_void);

Expand Down
1 change: 1 addition & 0 deletions src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use super::liblz4::*;
use std::io::{Error, ErrorKind, Result};

/// Represents the compression mode do be used.
#[derive(Debug)]
pub enum CompressionMode {
/// High compression with compression parameter
HIGHCOMPRESSION(i32),
Expand Down
2 changes: 2 additions & 0 deletions src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ use std::ptr;

const BUFFER_SIZE: usize = 32 * 1024;

#[derive(Debug)]
struct DecoderContext {
c: LZ4FDecompressionContext,
}

#[derive(Debug)]
pub struct Decoder<R> {
c: DecoderContext,
r: R,
Expand Down
4 changes: 3 additions & 1 deletion src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use std::io::Result;
use std::io::Write;
use std::ptr;

#[derive(Debug)]
struct EncoderContext {
c: LZ4FCompressionContext,
}

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct EncoderBuilder {
block_size: BlockSize,
block_mode: BlockMode,
Expand All @@ -20,6 +21,7 @@ pub struct EncoderBuilder {
auto_flush: bool,
}

#[derive(Debug)]
pub struct Encoder<W> {
c: EncoderContext,
w: W,
Expand Down

0 comments on commit 0a1d269

Please sign in to comment.