Skip to main content

reallyme_foundationdb_kit/keys/
namespace.rs

1// SPDX-FileCopyrightText: 2026 ReallyMe LLC
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Typed key namespaces.
5
6use crate::keys::{error::KeyLabelError, validation::validate_static_key_label};
7
8/// Stable namespace label for a family of keys.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct KeyNamespace {
11    value: &'static str,
12}
13
14impl KeyNamespace {
15    /// Creates a namespace from a compile-time allowlisted value.
16    pub fn from_static(value: &'static str) -> Result<Self, KeyLabelError> {
17        validate_static_key_label(value)?;
18        Ok(Self { value })
19    }
20
21    /// Returns the namespace label.
22    pub const fn as_str(self) -> &'static str {
23        self.value
24    }
25}