Skip to main content

runtime_capabilities/fidl/
mod.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
5mod capability;
6mod connector;
7mod connector_router;
8mod data;
9mod data_router;
10pub(crate) mod dictionary;
11mod dictionary_router;
12mod dir_connector;
13mod dir_connector_router;
14mod handle;
15mod instance_token;
16pub(crate) mod receiver;
17pub(crate) mod registry;
18pub(crate) mod router;
19pub(crate) mod store;
20
21use crate::{ConversionError, WeakInstanceToken};
22use fidl_fuchsia_component_sandbox as fsandbox;
23use std::sync::Arc;
24use vfs::directory::entry::DirectoryEntry;
25use vfs::execution_scope::ExecutionScope;
26
27pub trait IntoFsandboxCapability {
28    fn into_fsandbox_capability(self, _token: WeakInstanceToken) -> fsandbox::Capability
29    where
30        Self: Sized;
31}
32
33/// The trait which remotes Capabilities, either by turning them into
34/// FIDL or serving them in a VFS.
35pub trait RemotableCapability: IntoFsandboxCapability + Sized {
36    /// Attempt to convert `self` to a DirectoryEntry which can be served in a VFS. If routing
37    /// needs to be performed, `token` should be the `WeakInstanceToken` used for the route.
38    ///
39    /// The default implementation always returns an error.
40    fn try_into_directory_entry(
41        self,
42        _scope: ExecutionScope,
43        _token: WeakInstanceToken,
44    ) -> Result<Arc<dyn DirectoryEntry>, ConversionError> {
45        Err(ConversionError::NotSupported)
46    }
47}