runtime_capabilities/fidl/handle.rs
1// Copyright 2024 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 crate::{Handle, WeakInstanceToken};
6use fidl_fuchsia_component_sandbox as fsandbox;
7use std::sync::Arc;
8
9impl crate::fidl::IntoFsandboxCapability for Arc<Handle> {
10 fn into_fsandbox_capability(self, _token: Arc<WeakInstanceToken>) -> fsandbox::Capability {
11 // This is safe because this is only called during
12 // `fuchsia.component.sandbox.CapabilityStore/Export`, and by design it's not possible to
13 // export the same capability twice.
14 fsandbox::Capability::Handle(self.take().expect("failed to take handle"))
15 }
16}