Skip to main content

yugendb_core/
options.rs

1//! Operation option types.
2
3use std::time::Duration;
4
5/// Options for read operations.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct ReadOptions {
8    /// When true, a driver may return expired values.
9    pub allow_expired: bool,
10}
11
12impl Default for ReadOptions {
13    fn default() -> Self {
14        Self {
15            allow_expired: false,
16        }
17    }
18}
19
20/// Options for write operations.
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub struct WriteOptions {
23    /// Optional time-to-live duration.
24    pub ttl: Option<Duration>,
25    /// When false, setting an existing key should fail with a conflict.
26    pub overwrite: bool,
27}
28
29impl Default for WriteOptions {
30    fn default() -> Self {
31        Self {
32            ttl: None,
33            overwrite: true,
34        }
35    }
36}
37
38/// Options for delete operations.
39#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub struct DeleteOptions {
41    /// When true, deleting a missing key should fail.
42    pub must_exist: bool,
43}
44
45impl Default for DeleteOptions {
46    fn default() -> Self {
47        Self { must_exist: false }
48    }
49}
50
51/// Options for prefix scans.
52#[derive(Debug, Clone, PartialEq, Eq, Default)]
53pub struct ScanOptions {
54    /// Prefix to match against keys.
55    pub prefix: Option<String>,
56    /// Maximum number of records to return.
57    pub limit: Option<usize>,
58    /// When true, a driver may include expired values.
59    pub include_expired: bool,
60}