blob: 1dd6d9270a5e9c09e1fb956d297d963a939ea31a [file] [log] [blame]
Jooyung Han347d9f22021-05-28 00:05:14 +09001// Copyright 2021, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! VM Payload Config
16
17use log::info;
18use serde::{Deserialize, Serialize};
19use std::fs::File;
20use std::io;
21
22#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
23pub struct VmPayloadConfig {
24 #[serde(default)]
25 pub task: Option<Task>,
26}
27
28#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
29pub struct Task {
30 pub command: String,
31 #[serde(default)]
32 pub args: Vec<String>,
33}
34
35impl VmPayloadConfig {
36 pub fn load_from(path: &str) -> io::Result<VmPayloadConfig> {
37 info!("loading config from {}...", path);
38 let file = File::open(path)?;
39 Ok(serde_json::from_reader(file)?)
40 }
41}