Skip to main content

bits/
bits.rs

1// Copyright 2022 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
5// DO NOT EDIT.
6// Generated from FIDL library `zither.bits` by zither, a Fuchsia platform tool.
7
8use bitflags::bitflags;
9use zerocopy::{FromBytes, Immutable, IntoBytes};
10
11#[repr(C)]
12#[derive(
13    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
14)]
15pub struct Uint8Bits(u8);
16
17bitflags! {
18    impl Uint8Bits : u8 {
19        const ONE = 1 << 0;
20        const TWO = 1 << 1;
21        const FOUR = 1 << 2;
22        const EIGHT = 1 << 3;
23        const SIXTEEN = 1 << 4;
24        const THIRTY_TWO = 1 << 5;
25        const SIXTY_FOUR = 1 << 6;
26        const ONE_HUNDRED_TWENTY_EIGHT = 1 << 7;
27  }
28}
29
30#[repr(C)]
31#[derive(
32    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
33)]
34pub struct Uint16Bits(u16);
35
36bitflags! {
37    impl Uint16Bits : u16 {
38        const ZEROTH = 1 << 0;
39        const FIRST = 1 << 1;
40        const SECOND = 1 << 2;
41        const THIRD = 1 << 3;
42        const FOURTH = 1 << 4;
43        const FIFTH = 1 << 5;
44        const SIXTH = 1 << 6;
45        const SEVENTH = 1 << 7;
46        const EIGHT = 1 << 8;
47        const NINTH = 1 << 9;
48        const TENTH = 1 << 10;
49        const ELEVENTH = 1 << 11;
50        const TWELFTH = 1 << 12;
51        const THIRTEENTH = 1 << 13;
52        const FOURTEENTH = 1 << 14;
53        const FIFTHTEENTH = 1 << 15;
54  }
55}
56
57#[repr(C)]
58#[derive(
59    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
60)]
61pub struct Uint32Bits(u32);
62
63bitflags! {
64    impl Uint32Bits : u32 {
65        const POW_0 = 1 << 0;
66        const POW_31 = 1 << 31;
67  }
68}
69
70#[repr(C)]
71#[derive(
72    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
73)]
74pub struct Uint64Bits(u64);
75
76bitflags! {
77    impl Uint64Bits : u64 {
78        const POW_0 = 1 << 0;
79        const POW_63 = 1 << 63;
80  }
81}
82
83/// Bits with a one-line comment.
84#[repr(C)]
85#[derive(
86    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
87)]
88pub struct BitsWithOneLineComment(u8);
89
90bitflags! {
91    impl BitsWithOneLineComment : u8 {
92
93        /// Bits member with one-line comment.
94        const MEMBER_WITH_ONE_LINE_COMMENT = 1 << 0;
95
96        /// Bits member
97        ///     with a
98        ///         many-line
99        ///           comment.
100        const MEMBER_WITH_MANY_LINE_COMMENT = 1 << 6;
101  }
102}
103
104/// Bits
105///
106///     with a
107///         many-line
108///           comment.
109#[repr(C)]
110#[derive(
111    Immutable, IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
112)]
113pub struct BitsWithManyLineComment(u16);
114
115bitflags! {
116    impl BitsWithManyLineComment : u16 {
117        const MEMBER = 1 << 0;
118  }
119}
120
121pub const SEVENTY_TWO: Uint8Bits = Uint8Bits::from_bits_truncate(0b1001000); // Uint8Bits.SIXTY_FOUR | Uint8Bits.EIGHT
122
123pub const SOME_BITS: Uint16Bits = Uint16Bits::from_bits_truncate(0b1001000000010); // Uint16Bits.FIRST | Uint16Bits.NINTH | Uint16Bits.TWELFTH
124
125pub const U32_POW_0: Uint32Bits = Uint32Bits::POW_0;
126
127pub const U64_POW_63: Uint64Bits = Uint64Bits::POW_63;