Skip to main content

reifydb_core/interface/catalog/
namespace.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// Copyright (c) 2025 ReifyDB
3
4use crate::interface::catalog::id::NamespaceId;
5
6impl NamespaceId {
7	/// Root sentinel — all top-level namespaces have `parent_id: NamespaceId::ROOT`.
8	/// This is not a real namespace, just the tree root.
9	pub const ROOT: NamespaceId = NamespaceId(0);
10}
11
12#[derive(Debug, Clone, PartialEq)]
13pub struct NamespaceDef {
14	pub id: NamespaceId,
15	pub name: String,
16	pub parent_id: NamespaceId,
17}
18
19impl NamespaceDef {
20	pub fn system() -> Self {
21		Self {
22			id: NamespaceId(1),
23			name: "system".to_string(),
24			parent_id: NamespaceId::ROOT,
25		}
26	}
27
28	pub fn default_namespace() -> Self {
29		Self {
30			id: NamespaceId(2),
31			name: "default".to_string(),
32			parent_id: NamespaceId::ROOT,
33		}
34	}
35}