an efficient binary archive format

cleanup bindle.h

+8 -13
+1
cbindgen.toml
··· 1 1 language = "C" 2 2 header = "/* Auto-generated by cbindgen - do not edit manually */" 3 3 include_guard = "BINDLE_H" 4 + no_includes = true 4 5 sys_includes = ["stddef.h", "stdint.h", "stdbool.h"] 5 6 usize_is_size_t = true 6 7
+6 -12
include/bindle.h
··· 3 3 #ifndef BINDLE_H 4 4 #define BINDLE_H 5 5 6 - #include <stdarg.h> 7 - #include <stdbool.h> 8 - #include <stddef.h> 9 - #include <stdint.h> 10 - #include <stdlib.h> 11 6 #include <stddef.h> 12 7 #include <stdint.h> 13 8 #include <stdbool.h> ··· 15 10 /** 16 11 * Compression mode for entries. 17 12 */ 18 - enum BindleCompress { 13 + typedef enum BindleCompress { 19 14 /** 20 15 * No compression. 21 16 */ ··· 29 24 * Note: This is never stored on disk, only used as a policy hint. 30 25 */ 31 26 BindleCompressAuto = 2, 32 - }; 33 - typedef uint8_t BindleCompress; 27 + } BindleCompress; 34 28 35 29 /** 36 30 * A binary archive for collecting files. ··· 142 136 const char *name, 143 137 const uint8_t *data, 144 138 size_t data_len, 145 - BindleCompress compress); 139 + enum BindleCompress compress); 146 140 147 141 /** 148 142 * Adds a file from the filesystem to the archive. ··· 159 153 bool bindle_add_file(struct Bindle *ctx, 160 154 const char *name, 161 155 const char *path, 162 - BindleCompress compress); 156 + enum BindleCompress compress); 163 157 164 158 /** 165 159 * Commits all pending changes to disk. ··· 244 238 * 245 239 * Call `bindle_save()` to commit changes. 246 240 */ 247 - bool bindle_pack(struct Bindle *ctx, const char *src_path, BindleCompress compress); 241 + bool bindle_pack(struct Bindle *ctx, const char *src_path, enum BindleCompress compress); 248 242 249 243 /** 250 244 * Returns true if an entry with the given name exists. ··· 267 261 */ 268 262 struct BindleWriter *bindle_writer_new(struct Bindle *ctx, 269 263 const char *name, 270 - BindleCompress compress); 264 + enum BindleCompress compress); 271 265 272 266 /** 273 267 * Writes data to the writer.
+1 -1
src/compress.rs
··· 1 1 /// Compression mode for entries. 2 - #[repr(u8)] 2 + #[repr(C)] 3 3 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] 4 4 pub enum Compress { 5 5 /// No compression.