partiql_common/
catalog.rs

1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Hash)]
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6pub struct CatalogId(u64);
7
8impl From<u64> for CatalogId {
9    fn from(value: u64) -> Self {
10        CatalogId(value)
11    }
12}
13
14#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Hash)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub struct EntryId(u64);
17
18impl From<u64> for EntryId {
19    fn from(value: u64) -> Self {
20        EntryId(value)
21    }
22}
23
24#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Hash)]
25#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
26pub struct ObjectId {
27    catalog_id: CatalogId,
28    entry_id: EntryId,
29}
30
31impl ObjectId {
32    pub fn new(catalog_id: CatalogId, entry_id: EntryId) -> Self {
33        Self {
34            catalog_id,
35            entry_id,
36        }
37    }
38
39    pub fn catalog_id(&self) -> CatalogId {
40        self.catalog_id
41    }
42    pub fn entry_id(&self) -> EntryId {
43        self.entry_id
44    }
45}
46
47impl From<(CatalogId, EntryId)> for ObjectId {
48    fn from((catalog_id, entry_id): (CatalogId, EntryId)) -> Self {
49        ObjectId::new(catalog_id, entry_id)
50    }
51}