1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use {
    crate::types::Error,
    async_trait::async_trait,
    diagnostics_data::{Data, DiagnosticsData},
    serde::Serialize,
    std::fmt::Display,
};

#[async_trait]
pub trait Command {
    type Result: Serialize + Display;
    async fn execute<P: DiagnosticsProvider>(&self, provider: &P) -> Result<Self::Result, Error>;
}

#[async_trait]
pub trait DiagnosticsProvider: Send + Sync {
    async fn snapshot<D: DiagnosticsData>(
        &self,
        accessor: &Option<String>,
        selectors: &[String],
    ) -> Result<Vec<Data<D>>, Error>;

    /// Lists all ArchiveAccessor selectors.
    async fn get_accessor_paths(&self) -> Result<Vec<String>, Error>;
}