Skip to main content

reifydb_core/interface/catalog/
vtable.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4use serde::{Deserialize, Serialize};
5
6use crate::interface::catalog::{column::ColumnDef, id::NamespaceId};
7
8/// Unique identifier for a virtual table type
9#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
10pub struct VTableId(pub u64);
11
12impl From<u64> for VTableId {
13	fn from(id: u64) -> Self {
14		VTableId(id)
15	}
16}
17
18impl From<VTableId> for u64 {
19	fn from(id: VTableId) -> u64 {
20		id.0
21	}
22}
23
24impl VTableId {
25	/// Get the inner u64 value.
26	#[inline]
27	pub fn to_u64(self) -> u64 {
28		self.0
29	}
30}
31
32/// Definition of a virtual table, similar to TableDef but for virtual tables
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
34pub struct VTableDef {
35	/// Virtual table identifier
36	pub id: VTableId,
37	/// Namespace this virtual table belongs to
38	pub namespace: NamespaceId,
39	/// Name of the virtual table
40	pub name: String,
41	/// Column definitions
42	pub columns: Vec<ColumnDef>,
43}