teo_runtime/value/convert/into/
method.rs1use teo_result::Error;
2use hyper::Method;
3use crate::value::interface_enum_variant::InterfaceEnumVariant;
4use crate::value::Value;
5
6impl TryFrom<&Value> for Method {
7
8 type Error = Error;
9
10 fn try_from(value: &Value) -> Result<Self, Self::Error> {
11 let interface_enum_variant: InterfaceEnumVariant = value.try_into()?;
12 Ok(match interface_enum_variant.value.as_str() {
13 "post" => Method::POST,
14 "get" => Method::GET,
15 "patch" => Method::PATCH,
16 "put" => Method::PUT,
17 "delete" => Method::DELETE,
18 "options" => Method::OPTIONS,
19 "head" => Method::HEAD,
20 "connect" => Method::CONNECT,
21 "trace" => Method::TRACE,
22 _ => unreachable!(),
23 })
24 }
25}