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
use bytes::Bytes;

use fdb::error::FdbResult;
use fdb::range::StreamingMode;
use fdb::subspace::Subspace;
use fdb::transaction::ReadTransaction;

use crate::raw_record::{RawRecordCursor, RawRecordCursorBuilder};

use crate::scan::ScanLimiter;
use crate::RecordVersion;

pub use crate::raw_record::error::{RAW_RECORD_CURSOR_BUILDER_ERROR, RAW_RECORD_CURSOR_NEXT_ERROR};
pub use crate::raw_record::primary_key::{RawRecordPrimaryKey, RawRecordPrimaryKeySchema};
pub use crate::raw_record::RawRecord;

/// Expose [`RawRecordCursorBuilder::build`] method.
pub fn raw_record_cursor_builder_build<Tr>(
    primary_key_schema: Option<RawRecordPrimaryKeySchema>,
    subspace: Option<Subspace>,
    scan_limiter: Option<ScanLimiter>,
    streaming_mode: Option<StreamingMode>,
    limit: Option<usize>,
    reverse: Option<bool>,
    continuation: Option<Bytes>,
    read_transaction: &Tr,
) -> FdbResult<RawRecordCursor>
where
    Tr: ReadTransaction,
{
    let raw_record_cursor_builder = RawRecordCursorBuilder::from((
        primary_key_schema,
        subspace,
        scan_limiter,
        streaming_mode,
        limit,
        reverse,
        continuation,
    ));
    raw_record_cursor_builder.build(read_transaction)
}

/// Expose [`RawRecord::from`] method.
pub fn raw_record_from(
    primary_key: RawRecordPrimaryKey,
    version: RecordVersion,
    record_bytes: Bytes,
) -> RawRecord {
    RawRecord::from((primary_key, version, record_bytes))
}