#[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 = "TestType"] #[doc = r""] #[doc = r"
JSON schema"] #[doc = r""] #[doc = r" ```json"] #[doc = "{"] #[doc = " \"title\": \"TestType\","] #[doc = " \"type\": \"object\","] #[doc = " \"required\": ["] #[doc = " \"value\""] #[doc = " ],"] #[doc = " \"properties\": {"] #[doc = " \"value\": {"] #[doc = " \"enum\": ["] #[doc = " null,"] #[doc = " \"start\","] #[doc = " \"middle\","] #[doc = " \"end\""] #[doc = " ]"] #[doc = " }"] #[doc = " },"] #[doc = " \"$comment\": \"validate a type with no type and enum values that include a null\""] #[doc = "}"] #[doc = r" ```"] #[doc = r"
"] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] pub struct TestType { pub value: Option, } impl From<&TestType> for TestType { fn from(value: &TestType) -> Self { value.clone() } } #[doc = "TestTypeValue"] #[doc = r""] #[doc = r"
JSON schema"] #[doc = r""] #[doc = r" ```json"] #[doc = "{"] #[doc = " \"enum\": ["] #[doc = " null,"] #[doc = " \"start\","] #[doc = " \"middle\","] #[doc = " \"end\""] #[doc = " ]"] #[doc = "}"] #[doc = r" ```"] #[doc = r"
"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum TestTypeValue { #[serde(rename = "start")] Start, #[serde(rename = "middle")] Middle, #[serde(rename = "end")] End, } impl From<&TestTypeValue> for TestTypeValue { fn from(value: &TestTypeValue) -> Self { value.clone() } } impl ::std::fmt::Display for TestTypeValue { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Start => write!(f, "start"), Self::Middle => write!(f, "middle"), Self::End => write!(f, "end"), } } } impl std::str::FromStr for TestTypeValue { type Err = self::error::ConversionError; fn from_str(value: &str) -> Result { match value { "start" => Ok(Self::Start), "middle" => Ok(Self::Middle), "end" => Ok(Self::End), _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for TestTypeValue { type Error = self::error::ConversionError; fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for TestTypeValue { type Error = self::error::ConversionError; fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for TestTypeValue { type Error = self::error::ConversionError; fn try_from(value: String) -> Result { value.parse() } } fn main() {}