sandbox/
instance_token.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 fidl_fuchsia_component_sandbox as fsandbox;
6use std::any::Any;
7use std::fmt::Debug;
8use std::sync::Arc;
9
10/// The trait that `WeakInstanceToken` holds.
11pub trait WeakInstanceTokenAny: Debug + Send + Sync {
12    fn as_any(&self) -> &dyn Any;
13}
14
15/// A type representing a weak pointer to a component.
16/// This is type erased because the bedrock library shouldn't depend on
17/// Component Manager types.
18#[derive(Clone, Debug)]
19pub struct WeakInstanceToken {
20    pub inner: Arc<dyn WeakInstanceTokenAny>,
21}
22
23impl From<WeakInstanceToken> for fsandbox::Capability {
24    fn from(_component: WeakInstanceToken) -> Self {
25        todo!("b/337284929: Decide on if InstanceToken should be in Capability");
26    }
27}