settings/
config.rs

1// Copyright 2019 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::agent::AgentCreator;
6use settings_common::config::AgentType;
7
8#[macro_export]
9macro_rules! create_agent {
10    ($component:ident, $create:expr) => {
11        AgentCreator {
12            debug_id: concat!(stringify!($component), "_agent"),
13            create: $crate::agent::CreationFunc::Static(|c| Box::pin($create(c))),
14        }
15    };
16}
17
18impl AgentCreator {
19    pub(crate) fn from_type(agent_type: AgentType) -> Option<AgentCreator> {
20        use crate::agent::*;
21        Some(match agent_type {
22            AgentType::Earcons => create_agent!(earcons, earcons::agent::Agent::create),
23            AgentType::CameraWatcher
24            | AgentType::MediaButtons
25            | AgentType::InspectSettingValues
26            | AgentType::InspectExternalApis
27            | AgentType::InspectSettingProxy
28            | AgentType::InspectSettingTypeUsage => {
29                // Moved to lib.rs
30                return None;
31            }
32            AgentType::Restore => create_agent!(restore_agent, restore_agent::RestoreAgent::create),
33        })
34    }
35}