1pub use fidl_data_zx::ObjType as ObjectType;
6use fidl_data_zx::Rights;
7
8#[cfg(feature = "classic")]
9mod classic;
10#[cfg(feature = "classic")]
11pub use classic::*;
12
13#[cfg(feature = "fdomain")]
14mod fdomain;
15#[cfg(feature = "fdomain")]
16pub use fdomain::*;
17
18#[cfg(feature = "pure")]
19mod pure;
20#[cfg(feature = "pure")]
21pub use pure::*;
22pub trait CodecHandle {
23 type Channel : CodecChannel;
24
25 fn invalid() -> Self;
26
27 fn as_raw(&self) -> u32;
28 fn is_valid(&self) -> bool {
29 self.as_raw() != 0
30 }
31 fn is_invalid(&self) -> bool {
32 !self.is_valid()
33 }
34}
35
36pub trait CodecChannel {
37 type Handle : CodecHandle;
38 fn is_invalid(&self) -> bool;
39}
40
41pub struct HandleInfo {
42 pub handle: NullableHandle,
43 pub object_type: ObjectType,
44 pub rights: Rights,
45}
46
47impl HandleInfo {
48 pub fn new(handle: NullableHandle, object_type: ObjectType, rights: Rights) -> Self {
49 Self { handle, object_type, rights }
50 }
51 pub fn object_type(&self) -> ObjectType {
52 self.object_type
53 }
54 pub fn rights(&self) -> Rights {
55 self.rights
56 }
57 pub fn into_handle(self) -> NullableHandle {
58 self.handle
59 }
60}
61
62#[derive(Debug, PartialEq)]
63pub struct HandleDisposition {
64 pub handle: NullableHandle,
65 pub object_type: ObjectType,
66 pub rights: Rights,
67}
68
69impl HandleDisposition {
70 pub fn move_op(handle: NullableHandle, object_type: ObjectType, rights: Rights) -> Self {
71 Self { handle, object_type, rights }
72 }
73 pub fn raw_handle(&self) -> u32 {
74 self.handle.as_raw()
75 }
76}
77
78pub trait AsPlatform: Sized {
79 type PlatformType;
80 fn as_platform(&self) -> Self::PlatformType;
81}
82
83pub trait FromPlatform<PlatformType> {
84 fn from_platform(platform_type: PlatformType) -> Self;
85}