Skip to main content

mlt_core/frames/v01/id/
model.rs

1use crate::EncDec;
2use crate::v01::{EncodedStream, RawPresence, RawStream};
3
4/// ID column representation, either raw (borrowed from bytes) or parsed.
5pub type Id<'a> = EncDec<RawId<'a>, IdValues>;
6
7/// Unparsed ID data as read directly from the tile (borrows from input bytes)
8#[derive(Debug, PartialEq, Clone)]
9pub struct RawId<'a> {
10    pub(crate) presence: RawPresence<'a>,
11    pub(crate) value: RawIdValue<'a>,
12}
13
14/// A sequence of raw ID values, either 32-bit or 64-bit unsigned integers
15#[derive(Debug, PartialEq, Clone)]
16pub enum RawIdValue<'a> {
17    Id32(RawStream<'a>),
18    Id64(RawStream<'a>),
19}
20
21/// Parsed ID values as a vector of optional 64-bit unsigned integers
22#[derive(Clone, Default, PartialEq, Eq)]
23#[cfg_attr(all(not(test), feature = "arbitrary"), derive(arbitrary::Arbitrary))]
24pub struct IdValues(pub Vec<Option<u64>>);
25
26/// Wire-ready encoded ID data (owns its byte buffers)
27#[derive(Debug, PartialEq, Clone)]
28pub struct EncodedId {
29    pub(crate) presence: Option<EncodedStream>,
30    pub(crate) value: EncodedIdValue,
31}
32
33/// Wire-ready encoded ID value, either 32-bit or 64-bit
34#[derive(Debug, PartialEq, Clone)]
35pub enum EncodedIdValue {
36    Id32(EncodedStream),
37    Id64(EncodedStream),
38}
39
40/// How wide are the IDs
41#[derive(Debug, Clone, Copy, PartialEq, strum::EnumIter)]
42#[cfg_attr(all(not(test), feature = "arbitrary"), derive(arbitrary::Arbitrary))]
43pub enum IdWidth {
44    /// 32-bit encoding
45    Id32,
46    /// 32-bit encoding with nulls
47    OptId32,
48    /// 64-bit encoding (delta + zigzag + varint)
49    Id64,
50    /// 64-bit encoding with nulls
51    OptId64,
52}