Skip to main content

engine/filesystem/
detached_namespace.rs

1//! Detached namespaces.
2//!
3//! Detached namespaces are directories that are not reachable from the
4//! filesystem root. They have normal Engine identity, metadata,
5//! children, and events; they are simply outside the normal tree. The OS uses
6//! them for process state, network state, package state, and similar
7//! OS-meaningful stores.
8
9use crate::core::object_id::ObjectId;
10
11/// A handle to a detached namespace.
12///
13/// Obtain one from
14/// [`Engine::create_detached_namespace`](crate::engine::Engine::create_detached_namespace)
15/// and use its [`DetachedNamespace::id`] with ordinary Engine operations.
16#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
17pub struct DetachedNamespace {
18    id: ObjectId,
19}
20
21impl DetachedNamespace {
22    /// Wraps an object id as a namespace handle.
23    ///
24    /// The OS layer uses this to hold namespaces it created (or that were
25    /// created lazily) without re-querying the Engine.
26    pub fn new(id: ObjectId) -> Self {
27        Self { id }
28    }
29
30    /// The underlying object identity of this namespace.
31    pub fn id(self) -> ObjectId {
32        self.id
33    }
34}