Skip to main content

aliases/
aliases.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.aliases` by zither, a Fuchsia platform tool.
7
8use zerocopy::{IntoBytes, TryFromBytes};
9
10pub type BoolAlias = bool;
11
12pub type Int8Alias = i8;
13
14pub type Int16Alias = i16;
15
16pub type Int32Alias = i32;
17
18pub type Int64Alias = i64;
19
20pub type Uint8Alias = u8;
21
22pub type Uint16Alias = u16;
23
24pub type Uint32Alias = u32;
25
26pub type Uint64Alias = u64;
27
28/// TODO(https://fxbug.dev/42057022): The IR currently does not propagate enough
29/// information for bindings to express this type as an alias.
30pub const CONST_FROM_ALIAS: u8 = 0xff;
31
32#[repr(i16)]
33#[derive(Clone, Copy, Debug, Eq, Hash, IntoBytes, PartialEq, TryFromBytes)]
34pub enum Enum {
35    Member = 0,
36}
37
38impl Enum {
39    pub fn from_raw(raw: i16) -> Option<Self> {
40        match raw {
41            0 => Some(Self::Member),
42
43            _ => None,
44        }
45    }
46}
47
48impl From<Enum> for i16 {
49    fn from(val: Enum) -> Self {
50        val as Self
51    }
52}
53
54pub type EnumAlias = Enum;
55
56#[repr(u16)]
57#[derive(Clone, Copy, Debug, Eq, Hash, IntoBytes, PartialEq, TryFromBytes)]
58pub enum Bits {
59    One = 1,
60}
61
62impl Bits {
63    pub fn from_raw(raw: u16) -> Option<Self> {
64        match raw {
65            1 => Some(Self::One),
66
67            _ => None,
68        }
69    }
70}
71
72impl From<Bits> for u16 {
73    fn from(val: Bits) -> Self {
74        val as Self
75    }
76}
77
78pub type BitsAlias = Bits;
79
80#[repr(C)]
81#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromBytes)]
82pub struct Struct {
83    pub x: u64,
84    pub y: u64,
85    pub e: EnumAlias,
86}
87
88pub type StructAlias = Struct;
89
90pub type ArrayAlias = [u32; 4];
91
92pub type NestedArrayAlias = [[Struct; 8]; 4];
93
94/// Alias with a one-line comment.
95pub type AliasWithOneLineComment = bool;
96
97/// Alias
98///     with
99///         a
100///           many-line
101///             comment.
102pub type AliasWithManyLineComment = u8;