zx/
koid.rs

1// Copyright 2025 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::sys::zx_koid_t;
6
7/// The unique id assigned by kernel to the object referenced by a handle.
8///
9/// # Layout
10///
11/// This type is guaranteed to have the same layout and bit patterns as `zx_koid_t`.
12#[derive(
13    Debug,
14    Copy,
15    Clone,
16    Eq,
17    PartialEq,
18    Ord,
19    PartialOrd,
20    Hash,
21    zerocopy::FromBytes,
22    zerocopy::KnownLayout,
23    zerocopy::Immutable,
24)]
25#[repr(transparent)]
26pub struct Koid(zx_koid_t);
27
28impl Koid {
29    pub const fn from_raw(raw: zx_koid_t) -> Koid {
30        Koid(raw)
31    }
32
33    pub const fn raw_koid(&self) -> zx_koid_t {
34        self.0
35    }
36}