Skip to main content

selinux/new_policy/
types.rs

1// Copyright 2026 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 std::num::NonZeroU16;
6
7use super::bitmap::{IdSet, IdSetBuilder};
8use super::id_type::IdType;
9
10/// Tag type for type safety of policy type identifiers.
11#[derive(Copy, Clone, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)]
12pub struct TypeTag;
13
14/// Identifies a type (or type attribute) within a policy.
15pub type TypeId = IdType<NonZeroU16, TypeTag>;
16
17/// Set of types that are marked permissive.
18pub type PermissiveTypeSet = IdSet<TypeId, true>;
19
20/// Tag type for type safety of policy sensitivity identifiers.
21#[derive(Copy, Clone, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)]
22pub struct SensitivityTag;
23
24/// Identifies a sensitivity level within a policy.
25pub type SensitivityId = IdType<NonZeroU16, SensitivityTag>;
26
27/// Tag type for type safety of policy category identifiers.
28#[derive(Copy, Clone, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)]
29pub struct CategoryTag;
30
31/// Identifies a security category within a policy.
32pub type CategoryId = IdType<NonZeroU16, CategoryTag>;
33
34/// Set of security categories.
35pub type CategorySet = IdSet<CategoryId>;
36
37/// Builder for constructing [`CategorySet`]s dynamically.
38pub type CategorySetBuilder = IdSetBuilder<CategoryId>;