teo_runtime/value/convert/into/
runtime.rs1use crate::config::entity::Runtime;
2use teo_result::Error;
3use crate::value::interface_enum_variant::InterfaceEnumVariant;
4use crate::value::Value;
5
6impl TryFrom<Value> for Runtime {
7
8 type Error = Error;
9
10 fn try_from(ref value: Value) -> Result<Self, Self::Error> {
11 let interface_enum_variant: InterfaceEnumVariant = value.try_into()?;
12 match interface_enum_variant.value.as_str() {
13 "rust" => Ok(Runtime::Rust),
14 "node" => Ok(Runtime::Node),
15 "python" => Ok(Runtime::Python),
16 _ => Err(Error::new(format!("invalid runtime name: {:?}", value)))
17 }
18 }
19}