enclave_runner/command.rs
1/* Copyright (c) Fortanix, Inc.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7use anyhow::Error;
8
9type CommandFn = Box<dyn FnOnce() -> Result<(), Error>>;
10
11pub struct Command {
12 f: CommandFn
13}
14
15impl From<CommandFn> for Command {
16 fn from(f: CommandFn) -> Self {
17 Command {
18 f
19 }
20 }
21}
22
23impl Command {
24 pub fn run(self) -> Result<(), Error> {
25 (self.f)()
26 }
27}