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
52
53
54
55
56
57
58
59
60
61
62
63
//! A crate for reading DBN and legacy DBZ files and converting them to other
//! [`Encoding`](enums::Encoding)s.

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(clippy::missing_errors_doc)]

pub mod decode;
pub mod encode;
pub mod enums;
pub mod error;
#[doc(hidden)]
pub mod json_writer;
pub mod macros;
pub mod metadata;
pub mod pretty;
/// Enumerations for different data sources, venues, and publishers.
pub mod publishers;
#[cfg(feature = "python")]
pub mod python;
pub mod record;
pub mod record_ref;

pub use crate::error::{Error, Result};
pub use crate::metadata::{MappingInterval, Metadata, MetadataBuilder, SymbolMapping};

/// The current version of the DBN encoding, which is different from the crate version.
pub const DBN_VERSION: u8 = 1;
/// The length of Symbol fields (21 character maximum plus null-terminator)
pub const SYMBOL_CSTR_LEN: usize = 22;

const METADATA_DATASET_CSTR_LEN: usize = 16;
const METADATA_RESERVED_LEN: usize = 47;
/// Excludes magic string, version, and length.
const METADATA_FIXED_LEN: usize = 100;
const NULL_LIMIT: u64 = 0;
const NULL_RECORD_COUNT: u64 = u64::MAX;
const NULL_SCHEMA: u16 = u16::MAX;
const NULL_STYPE: u8 = u8::MAX;

/// The denominator of fixed prices in DBN.
pub const FIXED_PRICE_SCALE: i64 = 1_000_000_000;
/// The sentinel value for an unset or null price.
pub const UNDEF_PRICE: i64 = i64::MAX;
/// The sentinel value for an unset or null order quantity.
pub const UNDEF_ORDER_SIZE: u32 = u32::MAX;
/// The sentinel value for an unset or null stat quantity.
pub const UNDEF_STAT_QUANTITY: i32 = i32::MAX;
/// The sentinel value for an unset or null timestamp.
pub const UNDEF_TIMESTAMP: u64 = u64::MAX;

/// Contains dataset code constants.
pub mod datasets {
    /// The dataset code for Databento Equity Basic.
    pub const DBEQ_BASIC: &str = "DBEQ.BASIC";
    /// The dataset code for CME Globex MDP 3.0.
    pub const GLBX_MDP3: &str = "GLBX.MDP3";
    /// The dataset code for OPRA PILLAR.
    pub const OPRA_PILLAR: &str = "OPRA.PILLAR";
    /// The dataset code for Nasdaq TotalView ITCH.
    pub const XNAS_ITCH: &str = "XNAS.ITCH";
}