sandbox/
unit.rs

1// Copyright 2023 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.
4use crate::CapabilityBound;
5use fidl_fuchsia_component_sandbox as fsandbox;
6use std::fmt::Debug;
7
8#[derive(Debug, Clone, Default, PartialEq, Eq)]
9pub struct Unit;
10
11impl From<Unit> for fsandbox::Unit {
12    fn from(_unit: Unit) -> Self {
13        Self {}
14    }
15}
16
17impl From<Unit> for fsandbox::Capability {
18    fn from(unit: Unit) -> Self {
19        Self::Unit(unit.into())
20    }
21}
22
23impl CapabilityBound for Unit {
24    fn debug_typename() -> &'static str {
25        "Unit"
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn test_into_fidl() {
35        let unit = Unit::default();
36        let fidl_capability: fsandbox::Capability = unit.into();
37        assert_eq!(fidl_capability, fsandbox::Capability::Unit(fsandbox::Unit {}));
38    }
39}