katra-core 0.1.0

Katra3D core: shared vocabulary, error model, event model, IDs, and policy types.
Documentation
//! Event scope — which layer of the compatibility stack an event belongs to
//! (KatraProfiler §5).

use serde::{Deserialize, Serialize};

/// The layer of the stack that produced an event.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Scope {
    /// Windows-facing activity (NtReadFile, ReadFile, mappings, waits, ...).
    WindowsFacing,
    /// Wine/Proton activity (Windows→Unix transitions, server calls, ...).
    WineProton,
    /// Linux activity (syscalls, io_uring, page faults, scheduler, ...).
    Linux,
    /// D3D12/vkd3d activity (command lists, barriers, descriptors, PSOs, ...).
    D3d12Vkd3d,
    /// Vulkan activity (queue submissions, command buffers, ...).
    Vulkan,
    /// GPU activity (timestamps, idle bubbles, utilization).
    Gpu,
    /// Katra3D-native activity (graph ops, prefetch, staging, ...).
    Katra,
}

impl Scope {
    /// All scopes, in a stable order (append-only).
    pub const ALL: [Scope; 7] = [
        Scope::WindowsFacing,
        Scope::WineProton,
        Scope::Linux,
        Scope::D3d12Vkd3d,
        Scope::Vulkan,
        Scope::Gpu,
        Scope::Katra,
    ];

    /// Stable string name.
    pub const fn as_str(self) -> &'static str {
        match self {
            Scope::WindowsFacing => "windows_facing",
            Scope::WineProton => "wine_proton",
            Scope::Linux => "linux",
            Scope::D3d12Vkd3d => "d3d12_vkd3d",
            Scope::Vulkan => "vulkan",
            Scope::Gpu => "gpu",
            Scope::Katra => "katra",
        }
    }
}

impl std::fmt::Display for Scope {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}