nvtx 2.0.0

NVIDIA Tools Extension SDK
// SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

use crate::{common::CategoryEncodable, Domain};

/// Represents a domain-owned category for use with mark and range grouping.
///
/// See [`Domain::register_category`], [`Domain::register_categories`]
#[derive(Debug, Clone, Copy)]
pub struct Category<'a> {
    id: u32,
    domain: &'a Domain,
}

impl PartialEq for Category<'_> {
    fn eq(&self, other: &Self) -> bool {
        self.id == other.id && core::ptr::eq(self.domain, other.domain)
    }
}

impl Eq for Category<'_> {}

impl<'a> Category<'a> {
    pub(super) fn new(id: u32, domain: &'a Domain) -> Category<'a> {
        Category { id, domain }
    }

    pub(super) fn domain(&self) -> &Domain {
        self.domain
    }
}

impl CategoryEncodable for Category<'_> {
    fn encode_id(&self) -> u32 {
        self.id
    }
}