diff --git a/src/db_options.rs b/src/db_options.rs index fa3c9a4..b377085 100644 --- a/src/db_options.rs +++ b/src/db_options.rs @@ -657,6 +657,15 @@ impl BlockBasedOptions { ffi::rocksdb_block_based_options_set_whole_key_filtering(self.inner, c_uchar::from(v)); } } + + /// Use the specified checksum type. + /// Newly created table files will be protected with this checksum type. + /// Old table files will still be readable, even though they have different checksum type. + pub fn set_checksum_type(&mut self, checksum_type: ChecksumType) { + unsafe { + ffi::rocksdb_block_based_options_set_checksum(self.inner, checksum_type as c_char); + } + } } impl Default for BlockBasedOptions { @@ -3581,6 +3590,15 @@ pub enum MemtableFactory { }, } +/// Used by BlockBasedOptions::set_checksum_type. +pub enum ChecksumType { + NoChecksum = 0, + CRC32c = 1, + XXHash = 2, + XXHash64 = 3, + XXH3 = 4, // Supported since RocksDB 6.27 +} + /// Used with DBOptions::set_plain_table_factory. /// See official [wiki](https://github.com/facebook/rocksdb/wiki/PlainTable-Format) for more /// information. diff --git a/src/lib.rs b/src/lib.rs index 81ea602..9de4b86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,11 +111,11 @@ pub use crate::{ DBWALIterator, Direction, IteratorMode, }, db_options::{ - BlockBasedIndexType, BlockBasedOptions, BottommostLevelCompaction, Cache, CompactOptions, - CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath, DBRecoveryMode, - DataBlockIndexType, FifoCompactOptions, FlushOptions, IngestExternalFileOptions, LogLevel, - MemtableFactory, Options, PlainTableFactoryOptions, ReadOptions, UniversalCompactOptions, - UniversalCompactionStopStyle, WriteOptions, + BlockBasedIndexType, BlockBasedOptions, BottommostLevelCompaction, Cache, ChecksumType, + CompactOptions, CuckooTableOptions, DBCompactionStyle, DBCompressionType, DBPath, + DBRecoveryMode, DataBlockIndexType, FifoCompactOptions, FlushOptions, + IngestExternalFileOptions, LogLevel, MemtableFactory, Options, PlainTableFactoryOptions, + ReadOptions, UniversalCompactOptions, UniversalCompactionStopStyle, WriteOptions, }, db_pinnable_slice::DBPinnableSlice, env::Env,