mirror of
https://github.com/status-im/nim-rocksdb.git
synced 2025-02-18 09:57:04 +00:00
Several options were mistakenly classified as db options when in fact they are column family options - the C interface does not make this distinction and instead puts them all under one umbrella. This PR updates options to use nim setter/getter properties allowing both read and write of most options - lots of options are exposed both for reading and writing, but hey, one could always add _even more_ of them - there's certainly no lack!
42 lines
1.3 KiB
Nim
42 lines
1.3 KiB
Nim
# Nim-RocksDB
|
|
# Copyright 2024 Status Research & Development GmbH
|
|
# Licensed under either of
|
|
#
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
|
|
#
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
{.push raises: [].}
|
|
|
|
import
|
|
../lib/librocksdb
|
|
|
|
type
|
|
BackupEngineOptionsPtr* = ptr rocksdb_options_t
|
|
|
|
BackupEngineOptionsRef* = ref object
|
|
cPtr: BackupEngineOptionsPtr
|
|
|
|
proc newBackupEngineOptions*(): BackupEngineOptionsRef =
|
|
BackupEngineOptionsRef(cPtr: rocksdb_options_create())
|
|
|
|
proc isClosed*(engineOpts: BackupEngineOptionsRef): bool {.inline.} =
|
|
engineOpts.cPtr.isNil()
|
|
|
|
proc cPtr*(engineOpts: BackupEngineOptionsRef): BackupEngineOptionsPtr =
|
|
doAssert not engineOpts.isClosed()
|
|
engineOpts.cPtr
|
|
|
|
# TODO: Add setters and getters for backup options properties.
|
|
|
|
proc defaultBackupEngineOptions*(): BackupEngineOptionsRef {.inline.} =
|
|
let opts = newBackupEngineOptions()
|
|
opts
|
|
|
|
|
|
proc close*(engineOpts: BackupEngineOptionsRef) =
|
|
if not engineOpts.isClosed():
|
|
rocksdb_options_destroy(engineOpts.cPtr)
|
|
engineOpts.cPtr = nil
|