1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::ffi;

/// Compile mode
pub trait Mode {
    /// Id of mode
    const ID: u32;
    /// Name of mode
    const NAME: &'static str;

    /// The given database is a block database.
    fn is_block() -> bool {
        Self::ID == Block::ID
    }

    /// The given database is a block database.
    fn is_vectored() -> bool {
        Self::ID == Vectored::ID
    }

    /// The given database is a block database.
    fn is_streaming() -> bool {
        Self::ID == Streaming::ID
    }
}

/// Block scan (non-streaming) database.
#[derive(Debug, PartialEq, Eq)]
pub enum Block {}

/// Vectored scanning database.
#[derive(Debug, PartialEq, Eq)]
pub enum Vectored {}

/// Streaming database.
#[derive(Debug, PartialEq, Eq)]
pub enum Streaming {}

impl Mode for Block {
    const ID: u32 = ffi::HS_MODE_BLOCK;
    const NAME: &'static str = "Block";
}

impl Mode for Streaming {
    const ID: u32 = ffi::HS_MODE_STREAM;
    const NAME: &'static str = "Streaming";
}

impl Mode for Vectored {
    const ID: u32 = ffi::HS_MODE_VECTORED;
    const NAME: &'static str = "Vectored";
}