pub use super::generated_api::api::command::Command as ProtobufCommand; use crate::data::CommandToRun; use std::convert::TryFrom; use std::path::PathBuf; impl TryFrom for CommandToRun { type Error = &'static str; fn try_from(protobuf_command: ProtobufCommand) -> Result { let path = PathBuf::from(protobuf_command.path); let args = protobuf_command.args; let cwd = protobuf_command.cwd.map(|c| PathBuf::from(c)); Ok(CommandToRun { path, args, cwd }) } } impl TryFrom for ProtobufCommand { type Error = &'static str; fn try_from(command_to_run: CommandToRun) -> Result { Ok(ProtobufCommand { path: command_to_run.path.display().to_string(), args: command_to_run.args, cwd: command_to_run.cwd.map(|c| c.display().to_string()), }) } }