#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ImmunizationEvaluation {
pub id: Option<std::string::String>,
pub meta: Option<super::meta::Meta>,
pub implicit_rules: Option<super::primitives::Uri>,
pub language: Option<super::primitives::Code>,
pub text: Option<super::narrative::Narrative>,
pub contained: Vec<super::resource::Resource>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub identifier: Vec<super::identifier::Identifier>,
pub status: super::primitives::Code,
pub patient: super::reference::Reference,
pub date: Option<super::primitives::DateTime>,
pub authority: Option<super::reference::Reference>,
pub target_disease: super::codeable_concept::CodeableConcept,
pub immunization_event: super::reference::Reference,
pub dose_status: super::codeable_concept::CodeableConcept,
pub dose_status_reason: Vec<super::codeable_concept::CodeableConcept>,
pub description: Option<super::primitives::String>,
pub series: Option<super::primitives::String>,
pub dose_number: Option<ImmunizationEvaluationDoseNumber>,
pub series_doses: Option<ImmunizationEvaluationSeriesDoses>,
}
impl super::super::codec::Json for ImmunizationEvaluation {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
object.insert(
std::string::String::from("resourceType"),
super::super::codec::Value::String(std::string::String::from("ImmunizationEvaluation")),
);
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
if let Some(item) = &self.meta {
object.insert(
std::string::String::from("meta"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.implicit_rules {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("implicitRules"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_implicitRules"), e);
}
}
if let Some(item) = &self.language {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("language"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_language"), e);
}
}
if let Some(item) = &self.text {
object.insert(
std::string::String::from("text"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.contained.is_empty() {
let mut items = Vec::with_capacity(self.contained.len());
for item in &self.contained {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contained"),
super::super::codec::Value::Array(items),
);
}
if !self.extension.is_empty() {
let mut items = Vec::with_capacity(self.extension.len());
for item in &self.extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("extension"),
super::super::codec::Value::Array(items),
);
}
if !self.modifier_extension.is_empty() {
let mut items = Vec::with_capacity(self.modifier_extension.len());
for item in &self.modifier_extension {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("modifierExtension"),
super::super::codec::Value::Array(items),
);
}
if !self.identifier.is_empty() {
let mut items = Vec::with_capacity(self.identifier.len());
for item in &self.identifier {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("identifier"),
super::super::codec::Value::Array(items),
);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
object.insert(std::string::String::from("status"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
object.insert(std::string::String::from("_status"), e);
}
object.insert(
std::string::String::from("patient"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.patient)?),
);
if let Some(item) = &self.date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("date"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_date"), e);
}
}
if let Some(item) = &self.authority {
object.insert(
std::string::String::from("authority"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
object.insert(
std::string::String::from("targetDisease"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.target_disease,
)?),
);
object.insert(
std::string::String::from("immunizationEvent"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.immunization_event,
)?),
);
object.insert(
std::string::String::from("doseStatus"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.dose_status,
)?),
);
if !self.dose_status_reason.is_empty() {
let mut items = Vec::with_capacity(self.dose_status_reason.len());
for item in &self.dose_status_reason {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("doseStatusReason"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.description {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("description"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_description"), e);
}
}
if let Some(item) = &self.series {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("series"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_series"), e);
}
}
if let Some(item) = &self.dose_number {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("doseNumber{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_doseNumber{suffix}"), element);
}
}
if let Some(item) = &self.series_doses {
let (suffix, value, element) = item.to_json_parts()?;
if let Some(value) = value {
object.insert(format!("seriesDoses{suffix}"), value);
}
if let Some(element) = element {
object.insert(format!("_seriesDoses{suffix}"), element);
}
}
Ok(object)
}
fn from_json(
object: &super::super::codec::Object,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
let mut raw_id: Option<&super::super::codec::Value> = None;
let mut raw_meta: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
let mut raw_language: Option<&super::super::codec::Value> = None;
let mut raw_language_element: Option<&super::super::codec::Value> = None;
let mut raw_text: Option<&super::super::codec::Value> = None;
let mut raw_contained: Option<&super::super::codec::Value> = None;
let mut raw_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_identifier: Option<&super::super::codec::Value> = None;
let mut raw_status: Option<&super::super::codec::Value> = None;
let mut raw_status_element: Option<&super::super::codec::Value> = None;
let mut raw_patient: Option<&super::super::codec::Value> = None;
let mut raw_date: Option<&super::super::codec::Value> = None;
let mut raw_date_element: Option<&super::super::codec::Value> = None;
let mut raw_authority: Option<&super::super::codec::Value> = None;
let mut raw_target_disease: Option<&super::super::codec::Value> = None;
let mut raw_immunization_event: Option<&super::super::codec::Value> = None;
let mut raw_dose_status: Option<&super::super::codec::Value> = None;
let mut raw_dose_status_reason: Option<&super::super::codec::Value> = None;
let mut raw_description: Option<&super::super::codec::Value> = None;
let mut raw_description_element: Option<&super::super::codec::Value> = None;
let mut raw_series: Option<&super::super::codec::Value> = None;
let mut raw_series_element: Option<&super::super::codec::Value> = None;
let mut raw_dose_number = super::super::codec::ChoiceSlot::default();
let mut raw_series_doses = super::super::codec::ChoiceSlot::default();
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("ImmunizationEvaluation") {
return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
}
}
"id" => {
raw_id = Some(value);
}
"meta" => {
raw_meta = Some(value);
}
"implicitRules" => {
raw_implicit_rules = Some(value);
}
"_implicitRules" => {
raw_implicit_rules_element = Some(value);
}
"language" => {
raw_language = Some(value);
}
"_language" => {
raw_language_element = Some(value);
}
"text" => {
raw_text = Some(value);
}
"contained" => {
raw_contained = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"identifier" => {
raw_identifier = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"patient" => {
raw_patient = Some(value);
}
"date" => {
raw_date = Some(value);
}
"_date" => {
raw_date_element = Some(value);
}
"authority" => {
raw_authority = Some(value);
}
"targetDisease" => {
raw_target_disease = Some(value);
}
"immunizationEvent" => {
raw_immunization_event = Some(value);
}
"doseStatus" => {
raw_dose_status = Some(value);
}
"doseStatusReason" => {
raw_dose_status_reason = Some(value);
}
"description" => {
raw_description = Some(value);
}
"_description" => {
raw_description_element = Some(value);
}
"series" => {
raw_series = Some(value);
}
"_series" => {
raw_series_element = Some(value);
}
"doseNumberPositiveInt" => {
raw_dose_number.value("PositiveInt", value, path)?;
}
"_doseNumberPositiveInt" => {
raw_dose_number.element("PositiveInt", value, path)?;
}
"doseNumberString" => {
raw_dose_number.value("String", value, path)?;
}
"_doseNumberString" => {
raw_dose_number.element("String", value, path)?;
}
"seriesDosesPositiveInt" => {
raw_series_doses.value("PositiveInt", value, path)?;
}
"_seriesDosesPositiveInt" => {
raw_series_doses.element("PositiveInt", value, path)?;
}
"seriesDosesString" => {
raw_series_doses.value("String", value, path)?;
}
"_seriesDosesString" => {
raw_series_doses.element("String", value, path)?;
}
other => {
return path.with(other, |path| {
Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
});
}
}
}
let field_id = raw_id
.map(|value| {
path.with("id", |path| {
let value = super::super::codec::expect_single(value, path)?;
super::primitives::checked_id(
super::super::codec::expect_string(value, path)?,
path,
)
})
})
.transpose()?;
let field_meta = raw_meta
.map(|value| {
path.with("meta", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
(None, None) => None,
(value, element) => Some(path.with("implicitRules", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_language = match (raw_language, raw_language_element) {
(None, None) => None,
(value, element) => Some(path.with("language", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_text = raw_text
.map(|value| {
path.with("text", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let mut field_contained = Vec::new();
if let Some(raw) = raw_contained {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contained.push(path.with_index("contained", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_extension.push(path.with_index("extension", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_modifier_extension = Vec::new();
if let Some(raw) = raw_modifier_extension {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_modifier_extension.push(path.with_index(
"modifierExtension",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let mut field_identifier = Vec::new();
if let Some(raw) = raw_identifier {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_identifier.push(path.with_index("identifier", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let field_patient = path.with("patient", |path| {
let value = raw_patient
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let field_date = match (raw_date, raw_date_element) {
(None, None) => None,
(value, element) => Some(path.with("date", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_authority = raw_authority
.map(|value| {
path.with("authority", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_target_disease = path.with("targetDisease", |path| {
let value = raw_target_disease
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let field_immunization_event = path.with("immunizationEvent", |path| {
let value = raw_immunization_event
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let field_dose_status = path.with("doseStatus", |path| {
let value = raw_dose_status
.ok_or_else(|| path.error(super::super::codec::DecodeErrorKind::MissingProperty))?;
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})?;
let mut field_dose_status_reason = Vec::new();
if let Some(raw) = raw_dose_status_reason {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_dose_status_reason.push(path.with_index(
"doseStatusReason",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_description = match (raw_description, raw_description_element) {
(None, None) => None,
(value, element) => Some(path.with("description", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_series = match (raw_series, raw_series_element) {
(None, None) => None,
(value, element) => Some(path.with("series", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_dose_number = match raw_dose_number.suffix {
None => None,
Some(suffix) => Some(path.with("doseNumber", |path| {
ImmunizationEvaluationDoseNumber::from_json_parts(
suffix,
raw_dose_number.value,
raw_dose_number.element,
path,
)
})?),
};
let field_series_doses = match raw_series_doses.suffix {
None => None,
Some(suffix) => Some(path.with("seriesDoses", |path| {
ImmunizationEvaluationSeriesDoses::from_json_parts(
suffix,
raw_series_doses.value,
raw_series_doses.element,
path,
)
})?),
};
Ok(Self {
id: field_id,
meta: field_meta,
implicit_rules: field_implicit_rules,
language: field_language,
text: field_text,
contained: field_contained,
extension: field_extension,
modifier_extension: field_modifier_extension,
identifier: field_identifier,
status: field_status,
patient: field_patient,
date: field_date,
authority: field_authority,
target_disease: field_target_disease,
immunization_event: field_immunization_event,
dose_status: field_dose_status,
dose_status_reason: field_dose_status_reason,
description: field_description,
series: field_series,
dose_number: field_dose_number,
series_doses: field_series_doses,
})
}
}
impl serde::Serialize for ImmunizationEvaluation {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
if let Some(item) = &self.date {
super::super::codec::element_entry(&mut map, "_date", item)?;
}
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
match &self.dose_number {
Some(ImmunizationEvaluationDoseNumber::PositiveInt(inner)) => {
super::super::codec::element_entry(&mut map, "_doseNumberPositiveInt", inner)?;
}
Some(ImmunizationEvaluationDoseNumber::String(inner)) => {
super::super::codec::element_entry(&mut map, "_doseNumberString", inner)?;
}
None => {}
}
if let Some(item) = &self.implicit_rules {
super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
}
if let Some(item) = &self.language {
super::super::codec::element_entry(&mut map, "_language", item)?;
}
if let Some(item) = &self.series {
super::super::codec::element_entry(&mut map, "_series", item)?;
}
match &self.series_doses {
Some(ImmunizationEvaluationSeriesDoses::PositiveInt(inner)) => {
super::super::codec::element_entry(&mut map, "_seriesDosesPositiveInt", inner)?;
}
Some(ImmunizationEvaluationSeriesDoses::String(inner)) => {
super::super::codec::element_entry(&mut map, "_seriesDosesString", inner)?;
}
None => {}
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.authority {
serde::ser::SerializeMap::serialize_entry(&mut map, "authority", item)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if let Some(item) = &self.date {
super::super::codec::value_entry(&mut map, "date", item)?;
}
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", item)?;
}
match &self.dose_number {
Some(ImmunizationEvaluationDoseNumber::PositiveInt(inner)) => {
super::super::codec::value_entry(&mut map, "doseNumberPositiveInt", inner)?;
}
Some(ImmunizationEvaluationDoseNumber::String(inner)) => {
super::super::codec::value_entry(&mut map, "doseNumberString", inner)?;
}
None => {}
}
serde::ser::SerializeMap::serialize_entry(&mut map, "doseStatus", &self.dose_status)?;
if !self.dose_status_reason.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"doseStatusReason",
&self.dose_status_reason,
)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if !self.identifier.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
}
serde::ser::SerializeMap::serialize_entry(
&mut map,
"immunizationEvent",
&self.immunization_event,
)?;
if let Some(item) = &self.implicit_rules {
super::super::codec::value_entry(&mut map, "implicitRules", item)?;
}
if let Some(item) = &self.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if let Some(item) = &self.meta {
serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "patient", &self.patient)?;
serde::ser::SerializeMap::serialize_entry(
&mut map,
"resourceType",
"ImmunizationEvaluation",
)?;
if let Some(item) = &self.series {
super::super::codec::value_entry(&mut map, "series", item)?;
}
match &self.series_doses {
Some(ImmunizationEvaluationSeriesDoses::PositiveInt(inner)) => {
super::super::codec::value_entry(&mut map, "seriesDosesPositiveInt", inner)?;
}
Some(ImmunizationEvaluationSeriesDoses::String(inner)) => {
super::super::codec::value_entry(&mut map, "seriesDosesString", inner)?;
}
None => {}
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
serde::ser::SerializeMap::serialize_entry(&mut map, "targetDisease", &self.target_disease)?;
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for ImmunizationEvaluation {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
let mut path = super::super::codec::Path::root("ImmunizationEvaluation");
let object =
super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ImmunizationEvaluationDoseNumber {
PositiveInt(super::primitives::PositiveInt),
String(super::primitives::String),
}
impl ImmunizationEvaluationDoseNumber {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::PositiveInt(inner) => Ok((
"PositiveInt",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::String(inner) => Ok((
"String",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"PositiveInt" => Ok(Self::PositiveInt(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"String" => Ok(Self::String(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ImmunizationEvaluationSeriesDoses {
PositiveInt(super::primitives::PositiveInt),
String(super::primitives::String),
}
impl ImmunizationEvaluationSeriesDoses {
pub fn to_json_parts(
&self,
) -> Result<
(
&'static str,
Option<super::super::codec::Value>,
Option<super::super::codec::Value>,
),
super::super::codec::EncodeError,
> {
match self {
Self::PositiveInt(inner) => Ok((
"PositiveInt",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
Self::String(inner) => Ok((
"String",
super::super::codec::Primitive::value_json(inner)?,
super::super::codec::Primitive::element_json(inner)?,
)),
}
}
pub fn from_json_parts(
suffix: &str,
value: Option<&super::super::codec::Value>,
element: Option<&super::super::codec::Value>,
path: &mut super::super::codec::Path,
) -> Result<Self, super::super::codec::DecodeError> {
match suffix {
"PositiveInt" => Ok(Self::PositiveInt(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
"String" => Ok(Self::String(
super::super::codec::Primitive::from_json_parts(value, element, path)?,
)),
_ => Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty)),
}
}
}