sl4f_lib/factory_store/
types.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 serde::Deserialize;
6
7/// Supported factory commands.
8pub enum FactoryStoreMethod {
9    ListFiles,
10    ReadFile,
11}
12
13impl std::str::FromStr for FactoryStoreMethod {
14    type Err = anyhow::Error;
15
16    fn from_str(method: &str) -> Result<Self, Self::Err> {
17        match method {
18            "ListFiles" => Ok(FactoryStoreMethod::ListFiles),
19            "ReadFile" => Ok(FactoryStoreMethod::ReadFile),
20            _ => return Err(format_err!("invalid Factory FIDL method: {}", method)),
21        }
22    }
23}
24
25#[derive(Deserialize, Debug)]
26pub struct ListFilesRequest {
27    pub provider: FactoryStoreProvider,
28}
29
30#[derive(Deserialize, Debug)]
31pub struct ReadFileRequest {
32    pub provider: FactoryStoreProvider,
33    pub filename: String,
34}
35
36#[derive(Deserialize, Debug)]
37#[serde(rename_all = "camelCase")]
38pub enum FactoryStoreProvider {
39    Alpha,
40    Cast,
41    Misc,
42    Playready,
43    Weave,
44    Widevine,
45}