routing/bedrock/
aggregate_router.rs

1// Copyright 2025 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::capability_source::{AggregateInstance, CapabilitySource};
6use cm_rust::CapabilityTypeName;
7use cm_types::{Availability, Name};
8use sandbox::{DirEntry, Router};
9use std::sync::Arc;
10
11/// Functions of this signature are used during sandbox to construct new aggregate routers. These
12/// aggregate routers synthesize together one capability from multiple sources.
13pub type AggregateRouterFn<C> = dyn Fn(
14    Arc<C>,
15    Vec<AggregateSource>,
16    CapabilitySource,
17    CapabilityTypeName,
18    Availability,
19) -> Router<DirEntry>;
20
21/// An `AggregateSource` describes the source of one (or more) service capabilities whose instances
22/// will be added to an aggregated service.
23#[derive(Debug, Clone)]
24pub enum AggregateSource {
25    /// A router to a single service capability provider, whose published instances will be part of
26    /// an aggregate.
27    DirectoryRouter {
28        /// Where the router comes from, be it a parent, child, etc.
29        source_instance: AggregateInstance,
30        /// The router that will back this source to the aggregate.
31        router: Router<DirEntry>,
32    },
33    /// A collection whose dynamically created components may contribute to an aggregate.
34    Collection { collection_name: Name },
35}