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