vce-engine 0.1.1

The generic state substrate of the Virtual Computing Engine (VCE)
Documentation
//! Detached namespaces.
//!
//! Detached namespaces are directories that are not reachable from the
//! filesystem root. They have normal Engine identity, metadata,
//! children, and events; they are simply outside the normal tree. The OS uses
//! them for process state, network state, package state, and similar
//! OS-meaningful stores.

use crate::core::object_id::ObjectId;

/// A handle to a detached namespace.
///
/// Obtain one from
/// [`Engine::create_detached_namespace`](crate::engine::Engine::create_detached_namespace)
/// and use its [`DetachedNamespace::id`] with ordinary Engine operations.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct DetachedNamespace {
    id: ObjectId,
}

impl DetachedNamespace {
    /// Wraps an object id as a namespace handle.
    ///
    /// The OS layer uses this to hold namespaces it created (or that were
    /// created lazily) without re-querying the Engine.
    pub fn new(id: ObjectId) -> Self {
        Self { id }
    }

    /// The underlying object identity of this namespace.
    pub fn id(self) -> ObjectId {
        self.id
    }
}