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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
//! Types for table info request/response
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use super::action::{Add, Cdf, File, Metadata, Protocol, Remove};
/// Requested table version.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Version {
/// Latest table version.
Latest,
/// Earliest table version after the specified timestamp.
Timestamp(DateTime<Utc>),
}
/// Requested range of table version.
#[derive(Debug, Clone, Copy)]
pub enum VersionRange {
/// Range of table versions represented by start and end version number.
Version {
/// First timestamp that must be returned in the range.
start: u64,
/// Last timestamp that must be returned in the range.
end: u64,
},
/// Range of table versions represented by start and end timestamp.
Timestamp {
/// First version must be the earliest after the start timestamp.
start: DateTime<Utc>,
/// Last version must be the earliest after the end timestamp.
end: DateTime<Utc>,
},
}
/// Table version number.
pub type TableVersionNumber = u64;
/// Table metadata for a given table version.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TableMetadata {
/// Table version.
pub version: u64,
/// Minimum required table reader protocol implementation.
pub protocol: Protocol,
/// Table metadata
pub metadata: Metadata,
}
/// Table metadata and data descriptors, not yet publicly accessible.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct UnsignedTableData {
/// Table version.
pub version: u64,
/// Minimum required table reader protocol implementation.
pub protocol: Protocol,
/// Table metadata
pub metadata: Metadata,
/// Set of data file representing the table
pub data: Vec<UnsignedDataFile>,
}
/// Table metadata and data descriptors with presigned urls.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct SignedTableData {
/// Table version.
pub version: u64,
/// Minimum required table reader protocol implementation.
pub protocol: Protocol,
/// Table metadata
pub metadata: Metadata,
/// Set of data file representing the table
pub data: Vec<SignedDataFile>,
}
/// A representation of data or mutation in a table referenced using an object
/// store url.
///
/// A table is represented as a set of files that together are the full table.
/// Every data file has a reference to the underlying object store in its url
/// field.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum UnsignedDataFile {
/// A file containing data part of the table.
File(File),
/// A file containing data that was added to the table in this version.
Add(Add),
/// A file containing data that was changed in this version of the table.
Cdf(Cdf),
/// A file containing data that was removed since the last table version.
Remove(Remove),
}
/// A representation of data or mutation in a table reachable with a presigned
/// url.
///
/// A table is represented as a set of files that together are the full table.
/// Every data file has a presigned url that can be used to directly access the
/// data file.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum SignedDataFile {
/// A file containing data part of the table.
File(File),
/// A file containing data that was added to the table in this version.
Add(Add),
/// A file containing data that was changed in this version of the table.
Cdf(Cdf),
/// A file containing data that was removed since the last table version.
Remove(Remove),
}
impl From<File> for UnsignedDataFile {
fn from(v: File) -> Self {
Self::File(v)
}
}
impl From<Add> for UnsignedDataFile {
fn from(v: Add) -> Self {
Self::Add(v)
}
}
impl From<Cdf> for UnsignedDataFile {
fn from(v: Cdf) -> Self {
Self::Cdf(v)
}
}
impl From<Remove> for UnsignedDataFile {
fn from(v: Remove) -> Self {
Self::Remove(v)
}
}