Debian Codegraph @

src/lz4f/frame_info.rs

raw symbols SCIP
1 use std::os::raw::{c_uint, c_ulonglong};
2
3 /// Block size flag.
4 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5 #[non_exhaustive]
6 #[repr(C)]
7 pub enum BlockSize {
8 Default = 0,
9 Max64KB = 4,
10 Max256KB = 5,
11 Max1MB = 6,
12 Max4MB = 7,
13 }
14
15 impl Default for BlockSize {
16 fn default() -> Self {
17 Self::Default
18 }
19 }
20
21 /// Block mode flag.
22 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
23 #[repr(C)]
24 pub enum BlockMode {
25 Linked,
26 Independent,
27 }
28
29 impl Default for BlockMode {
30 fn default() -> Self {
31 Self::Linked
32 }
33 }
34
35 /// Content checksum flag.
36 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
37 #[repr(C)]
38 pub enum ContentChecksum {
39 Disabled,
40 Enabled,
41 }
42
43 impl Default for ContentChecksum {
44 fn default() -> Self {
45 Self::Disabled
46 }
47 }
48
49 /// Frame type flag.
50 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
51 #[repr(C)]
52 pub enum FrameType {
53 Frame,
54 SkippableFrame,
55 }
56
57 impl Default for FrameType {
58 fn default() -> Self {
59 Self::Frame
60 }
61 }
62
63 /// Block checksum flag.
64 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
65 #[repr(C)]
66 pub enum BlockChecksum {
67 Disabled,
68 Enabled,
69 }
70
71 impl Default for BlockChecksum {
72 fn default() -> Self {
73 Self::Disabled
74 }
75 }
76
77 /// LZ4 Frame parameters.
78 #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)]
79 #[repr(C)]
80 pub struct FrameInfo {
81 block_size: BlockSize,
82 block_mode: BlockMode,
83 content_checksum: ContentChecksum,
84 frame_type: FrameType,
85 content_size: c_ulonglong,
86 dict_id: c_uint,
87 block_checksum: BlockChecksum,
88 }
89
90 impl FrameInfo {
91 /// Returns the block size.
92 pub const fn block_size(&self) -> BlockSize {
93 self.block_size
94 }
95
96 /// Returns the block mode.
97 pub const fn block_mode(&self) -> BlockMode {
98 self.block_mode
99 }
100
101 /// Returns the content checksum.
102 pub const fn content_checksum(&self) -> ContentChecksum {
103 self.content_checksum
104 }
105
106 /// Returns the frame type.
107 pub const fn frame_type(&self) -> FrameType {
108 self.frame_type
109 }
110
111 /// Returns the content size.
112 pub const fn content_size(&self) -> usize {
113 self.content_size as usize
114 }
115
116 /// Returns the dictionary id.
117 pub const fn dict_id(&self) -> u32 {
118 self.dict_id
119 }
120
121 /// Returns the block checksum.
122 pub const fn block_checksum(&self) -> BlockChecksum {
123 self.block_checksum
124 }
125
126 pub(super) fn set_block_size(&mut self, block_size: BlockSize) {
127 self.block_size = block_size;
128 }
129
130 pub(super) fn set_block_mode(&mut self, block_mode: BlockMode) {
131 self.block_mode = block_mode;
132 }
133
134 pub(super) fn set_content_checksum(&mut self, checksum: ContentChecksum) {
135 self.content_checksum = checksum;
136 }
137
138 pub(super) fn set_content_size(&mut self, size: usize) {
139 self.content_size = size as c_ulonglong;
140 }
141
142 pub(super) fn set_dict_id(&mut self, dict_id: u32) {
143 self.dict_id = dict_id as c_uint;
144 }
145
146 pub(super) fn set_block_checksum(&mut self, checksum: BlockChecksum) {
147 self.block_checksum = checksum;
148 }
149 }