#[doc = r" Error types."] pub mod error { #[doc = r" Error from a TryFrom or FromStr implementation."] pub struct ConversionError(::std::borrow::Cow<'static, str>); impl ::std::error::Error for ConversionError {} impl ::std::fmt::Display for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Display::fmt(&self.0, f) } } impl ::std::fmt::Debug for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Debug::fmt(&self.0, f) } } impl From<&'static str> for ConversionError { fn from(value: &'static str) -> Self { Self(value.into()) } } impl From for ConversionError { fn from(value: String) -> Self { Self(value.into()) } } } #[doc = "TestEnum"] #[doc = r""] #[doc = r"
JSON schema"] #[doc = r""] #[doc = r" ```json"] #[doc = "{"] #[doc = " \"default\": \"failure\","] #[doc = " \"type\": \"string\","] #[doc = " \"enum\": ["] #[doc = " \"failure\","] #[doc = " \"skipped\","] #[doc = " \"success\""] #[doc = " ]"] #[doc = "}"] #[doc = r" ```"] #[doc = r"
"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum TestEnum { #[serde(rename = "failure")] Failure, #[serde(rename = "skipped")] Skipped, #[serde(rename = "success")] Success, } impl From<&TestEnum> for TestEnum { fn from(value: &TestEnum) -> Self { value.clone() } } impl ::std::fmt::Display for TestEnum { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Failure => write!(f, "failure"), Self::Skipped => write!(f, "skipped"), Self::Success => write!(f, "success"), } } } impl std::str::FromStr for TestEnum { type Err = self::error::ConversionError; fn from_str(value: &str) -> Result { match value { "failure" => Ok(Self::Failure), "skipped" => Ok(Self::Skipped), "success" => Ok(Self::Success), _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for TestEnum { type Error = self::error::ConversionError; fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for TestEnum { type Error = self::error::ConversionError; fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for TestEnum { type Error = self::error::ConversionError; fn try_from(value: String) -> Result { value.parse() } } impl Default for TestEnum { fn default() -> Self { TestEnum::Failure } } fn main() {}