#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct VerificationResult {
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 target: Vec<super::reference::Reference>,
pub target_location: Vec<super::primitives::String>,
pub need: Option<super::codeable_concept::CodeableConcept>,
pub status: super::primitives::Code,
pub status_date: Option<super::primitives::DateTime>,
pub validation_type: Option<super::codeable_concept::CodeableConcept>,
pub validation_process: Vec<super::codeable_concept::CodeableConcept>,
pub frequency: Option<super::timing::Timing>,
pub last_performed: Option<super::primitives::DateTime>,
pub next_scheduled: Option<super::primitives::Date>,
pub failure_action: Option<super::codeable_concept::CodeableConcept>,
pub primary_source: Vec<VerificationResultPrimarySource>,
pub attestation: Option<VerificationResultAttestation>,
pub validator: Vec<VerificationResultValidator>,
}
impl super::super::codec::Json for VerificationResult {
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("VerificationResult")),
);
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.target.is_empty() {
let mut items = Vec::with_capacity(self.target.len());
for item in &self.target {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("target"),
super::super::codec::Value::Array(items),
);
}
if !self.target_location.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.target_location)?;
if let Some(values) = values {
object.insert(std::string::String::from("targetLocation"), values);
}
if let Some(elements) = elements {
object.insert(std::string::String::from("_targetLocation"), elements);
}
}
if let Some(item) = &self.need {
object.insert(
std::string::String::from("need"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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);
}
if let Some(item) = &self.status_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("statusDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_statusDate"), e);
}
}
if let Some(item) = &self.validation_type {
object.insert(
std::string::String::from("validationType"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.validation_process.is_empty() {
let mut items = Vec::with_capacity(self.validation_process.len());
for item in &self.validation_process {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("validationProcess"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.frequency {
object.insert(
std::string::String::from("frequency"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.last_performed {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("lastPerformed"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_lastPerformed"), e);
}
}
if let Some(item) = &self.next_scheduled {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("nextScheduled"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_nextScheduled"), e);
}
}
if let Some(item) = &self.failure_action {
object.insert(
std::string::String::from("failureAction"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.primary_source.is_empty() {
let mut items = Vec::with_capacity(self.primary_source.len());
for item in &self.primary_source {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("primarySource"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.attestation {
object.insert(
std::string::String::from("attestation"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.validator.is_empty() {
let mut items = Vec::with_capacity(self.validator.len());
for item in &self.validator {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("validator"),
super::super::codec::Value::Array(items),
);
}
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_target: Option<&super::super::codec::Value> = None;
let mut raw_target_location: Option<&super::super::codec::Value> = None;
let mut raw_target_location_element: Option<&super::super::codec::Value> = None;
let mut raw_need: 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_status_date: Option<&super::super::codec::Value> = None;
let mut raw_status_date_element: Option<&super::super::codec::Value> = None;
let mut raw_validation_type: Option<&super::super::codec::Value> = None;
let mut raw_validation_process: Option<&super::super::codec::Value> = None;
let mut raw_frequency: Option<&super::super::codec::Value> = None;
let mut raw_last_performed: Option<&super::super::codec::Value> = None;
let mut raw_last_performed_element: Option<&super::super::codec::Value> = None;
let mut raw_next_scheduled: Option<&super::super::codec::Value> = None;
let mut raw_next_scheduled_element: Option<&super::super::codec::Value> = None;
let mut raw_failure_action: Option<&super::super::codec::Value> = None;
let mut raw_primary_source: Option<&super::super::codec::Value> = None;
let mut raw_attestation: Option<&super::super::codec::Value> = None;
let mut raw_validator: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("VerificationResult") {
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);
}
"target" => {
raw_target = Some(value);
}
"targetLocation" => {
raw_target_location = Some(value);
}
"_targetLocation" => {
raw_target_location_element = Some(value);
}
"need" => {
raw_need = Some(value);
}
"status" => {
raw_status = Some(value);
}
"_status" => {
raw_status_element = Some(value);
}
"statusDate" => {
raw_status_date = Some(value);
}
"_statusDate" => {
raw_status_date_element = Some(value);
}
"validationType" => {
raw_validation_type = Some(value);
}
"validationProcess" => {
raw_validation_process = Some(value);
}
"frequency" => {
raw_frequency = Some(value);
}
"lastPerformed" => {
raw_last_performed = Some(value);
}
"_lastPerformed" => {
raw_last_performed_element = Some(value);
}
"nextScheduled" => {
raw_next_scheduled = Some(value);
}
"_nextScheduled" => {
raw_next_scheduled_element = Some(value);
}
"failureAction" => {
raw_failure_action = Some(value);
}
"primarySource" => {
raw_primary_source = Some(value);
}
"attestation" => {
raw_attestation = Some(value);
}
"validator" => {
raw_validator = Some(value);
}
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 path
.with("contained", |path| {
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 path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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_target = Vec::new();
if let Some(raw) = raw_target {
for (index, value) in path
.with("target", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_target.push(path.with_index("target", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_target_location = Vec::new();
for (index, (value, element)) in path
.with("targetLocation", |path| {
super::super::codec::pair_arrays(
raw_target_location,
raw_target_location_element,
path,
)
})?
.into_iter()
.enumerate()
{
field_target_location.push(path.with_index("targetLocation", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let field_need = raw_need
.map(|value| {
path.with("need", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let field_status_date = match (raw_status_date, raw_status_date_element) {
(None, None) => None,
(value, element) => Some(path.with("statusDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_validation_type = raw_validation_type
.map(|value| {
path.with("validationType", |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_validation_process = Vec::new();
if let Some(raw) = raw_validation_process {
for (index, value) in path
.with("validationProcess", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_validation_process.push(path.with_index(
"validationProcess",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_frequency = raw_frequency
.map(|value| {
path.with("frequency", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_last_performed = match (raw_last_performed, raw_last_performed_element) {
(None, None) => None,
(value, element) => Some(path.with("lastPerformed", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_next_scheduled = match (raw_next_scheduled, raw_next_scheduled_element) {
(None, None) => None,
(value, element) => Some(path.with("nextScheduled", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_failure_action = raw_failure_action
.map(|value| {
path.with("failureAction", |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_primary_source = Vec::new();
if let Some(raw) = raw_primary_source {
for (index, value) in path
.with("primarySource", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_primary_source.push(path.with_index("primarySource", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_attestation = raw_attestation
.map(|value| {
path.with("attestation", |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_validator = Vec::new();
if let Some(raw) = raw_validator {
for (index, value) in path
.with("validator", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_validator.push(path.with_index("validator", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
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,
target: field_target,
target_location: field_target_location,
need: field_need,
status: field_status,
status_date: field_status_date,
validation_type: field_validation_type,
validation_process: field_validation_process,
frequency: field_frequency,
last_performed: field_last_performed,
next_scheduled: field_next_scheduled,
failure_action: field_failure_action,
primary_source: field_primary_source,
attestation: field_attestation,
validator: field_validator,
})
}
}
impl serde::Serialize for VerificationResult {
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.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.last_performed {
super::super::codec::element_entry(&mut map, "_lastPerformed", item)?;
}
if let Some(item) = &self.next_scheduled {
super::super::codec::element_entry(&mut map, "_nextScheduled", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.status_date {
super::super::codec::element_entry(&mut map, "_statusDate", item)?;
}
super::super::codec::element_list_entry(
&mut map,
"_targetLocation",
&self.target_location,
)?;
if let Some(item) = &self.attestation {
serde::ser::SerializeMap::serialize_entry(&mut map, "attestation", item)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
if let Some(item) = &self.failure_action {
serde::ser::SerializeMap::serialize_entry(&mut map, "failureAction", item)?;
}
if let Some(item) = &self.frequency {
serde::ser::SerializeMap::serialize_entry(&mut map, "frequency", item)?;
}
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
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.last_performed {
super::super::codec::value_entry(&mut map, "lastPerformed", 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,
)?;
}
if let Some(item) = &self.need {
serde::ser::SerializeMap::serialize_entry(&mut map, "need", item)?;
}
if let Some(item) = &self.next_scheduled {
super::super::codec::value_entry(&mut map, "nextScheduled", item)?;
}
if !self.primary_source.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"primarySource",
&self.primary_source,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "VerificationResult")?;
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if let Some(item) = &self.status_date {
super::super::codec::value_entry(&mut map, "statusDate", item)?;
}
if !self.target.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "target", &self.target)?;
}
super::super::codec::value_list_entry(&mut map, "targetLocation", &self.target_location)?;
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
if !self.validation_process.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"validationProcess",
&self.validation_process,
)?;
}
if let Some(item) = &self.validation_type {
serde::ser::SerializeMap::serialize_entry(&mut map, "validationType", item)?;
}
if !self.validator.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "validator", &self.validator)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for VerificationResult {
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("VerificationResult");
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, Default, PartialEq, Eq)]
pub struct VerificationResultAttestation {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub who: Option<super::reference::Reference>,
pub on_behalf_of: Option<super::reference::Reference>,
pub communication_method: Option<super::codeable_concept::CodeableConcept>,
pub date: Option<super::primitives::Date>,
pub source_identity_certificate: Option<super::primitives::String>,
pub proxy_identity_certificate: Option<super::primitives::String>,
pub proxy_signature: Option<super::signature::Signature>,
pub source_signature: Option<super::signature::Signature>,
}
impl super::super::codec::Json for VerificationResultAttestation {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
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 let Some(item) = &self.who {
object.insert(
std::string::String::from("who"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.on_behalf_of {
object.insert(
std::string::String::from("onBehalfOf"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.communication_method {
object.insert(
std::string::String::from("communicationMethod"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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.source_identity_certificate {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("sourceIdentityCertificate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_sourceIdentityCertificate"), e);
}
}
if let Some(item) = &self.proxy_identity_certificate {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("proxyIdentityCertificate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_proxyIdentityCertificate"), e);
}
}
if let Some(item) = &self.proxy_signature {
object.insert(
std::string::String::from("proxySignature"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.source_signature {
object.insert(
std::string::String::from("sourceSignature"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_who: Option<&super::super::codec::Value> = None;
let mut raw_on_behalf_of: Option<&super::super::codec::Value> = None;
let mut raw_communication_method: 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_source_identity_certificate: Option<&super::super::codec::Value> = None;
let mut raw_source_identity_certificate_element: Option<&super::super::codec::Value> = None;
let mut raw_proxy_identity_certificate: Option<&super::super::codec::Value> = None;
let mut raw_proxy_identity_certificate_element: Option<&super::super::codec::Value> = None;
let mut raw_proxy_signature: Option<&super::super::codec::Value> = None;
let mut raw_source_signature: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"who" => {
raw_who = Some(value);
}
"onBehalfOf" => {
raw_on_behalf_of = Some(value);
}
"communicationMethod" => {
raw_communication_method = Some(value);
}
"date" => {
raw_date = Some(value);
}
"_date" => {
raw_date_element = Some(value);
}
"sourceIdentityCertificate" => {
raw_source_identity_certificate = Some(value);
}
"_sourceIdentityCertificate" => {
raw_source_identity_certificate_element = Some(value);
}
"proxyIdentityCertificate" => {
raw_proxy_identity_certificate = Some(value);
}
"_proxyIdentityCertificate" => {
raw_proxy_identity_certificate_element = Some(value);
}
"proxySignature" => {
raw_proxy_signature = Some(value);
}
"sourceSignature" => {
raw_source_signature = Some(value);
}
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_string(
super::super::codec::expect_string(value, path)?,
path,
)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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 field_who = raw_who
.map(|value| {
path.with("who", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_on_behalf_of = raw_on_behalf_of
.map(|value| {
path.with("onBehalfOf", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_communication_method = raw_communication_method
.map(|value| {
path.with("communicationMethod", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
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_source_identity_certificate = match (
raw_source_identity_certificate,
raw_source_identity_certificate_element,
) {
(None, None) => None,
(value, element) => Some(path.with("sourceIdentityCertificate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_proxy_identity_certificate = match (
raw_proxy_identity_certificate,
raw_proxy_identity_certificate_element,
) {
(None, None) => None,
(value, element) => Some(path.with("proxyIdentityCertificate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_proxy_signature = raw_proxy_signature
.map(|value| {
path.with("proxySignature", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_source_signature = raw_source_signature
.map(|value| {
path.with("sourceSignature", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
who: field_who,
on_behalf_of: field_on_behalf_of,
communication_method: field_communication_method,
date: field_date,
source_identity_certificate: field_source_identity_certificate,
proxy_identity_certificate: field_proxy_identity_certificate,
proxy_signature: field_proxy_signature,
source_signature: field_source_signature,
})
}
}
impl serde::Serialize for VerificationResultAttestation {
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.proxy_identity_certificate {
super::super::codec::element_entry(&mut map, "_proxyIdentityCertificate", item)?;
}
if let Some(item) = &self.source_identity_certificate {
super::super::codec::element_entry(&mut map, "_sourceIdentityCertificate", item)?;
}
if let Some(item) = &self.communication_method {
serde::ser::SerializeMap::serialize_entry(&mut map, "communicationMethod", item)?;
}
if let Some(item) = &self.date {
super::super::codec::value_entry(&mut map, "date", item)?;
}
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.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if let Some(item) = &self.on_behalf_of {
serde::ser::SerializeMap::serialize_entry(&mut map, "onBehalfOf", item)?;
}
if let Some(item) = &self.proxy_identity_certificate {
super::super::codec::value_entry(&mut map, "proxyIdentityCertificate", item)?;
}
if let Some(item) = &self.proxy_signature {
serde::ser::SerializeMap::serialize_entry(&mut map, "proxySignature", item)?;
}
if let Some(item) = &self.source_identity_certificate {
super::super::codec::value_entry(&mut map, "sourceIdentityCertificate", item)?;
}
if let Some(item) = &self.source_signature {
serde::ser::SerializeMap::serialize_entry(&mut map, "sourceSignature", item)?;
}
if let Some(item) = &self.who {
serde::ser::SerializeMap::serialize_entry(&mut map, "who", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for VerificationResultAttestation {
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("VerificationResultAttestation");
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, Default, PartialEq, Eq)]
pub struct VerificationResultPrimarySource {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub who: Option<super::reference::Reference>,
pub r#type: Vec<super::codeable_concept::CodeableConcept>,
pub communication_method: Vec<super::codeable_concept::CodeableConcept>,
pub validation_status: Option<super::codeable_concept::CodeableConcept>,
pub validation_date: Option<super::primitives::DateTime>,
pub can_push_updates: Option<super::codeable_concept::CodeableConcept>,
pub push_type_available: Vec<super::codeable_concept::CodeableConcept>,
}
impl super::super::codec::Json for VerificationResultPrimarySource {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
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 let Some(item) = &self.who {
object.insert(
std::string::String::from("who"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.r#type.is_empty() {
let mut items = Vec::with_capacity(self.r#type.len());
for item in &self.r#type {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("type"),
super::super::codec::Value::Array(items),
);
}
if !self.communication_method.is_empty() {
let mut items = Vec::with_capacity(self.communication_method.len());
for item in &self.communication_method {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("communicationMethod"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.validation_status {
object.insert(
std::string::String::from("validationStatus"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.validation_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("validationDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_validationDate"), e);
}
}
if let Some(item) = &self.can_push_updates {
object.insert(
std::string::String::from("canPushUpdates"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.push_type_available.is_empty() {
let mut items = Vec::with_capacity(self.push_type_available.len());
for item in &self.push_type_available {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("pushTypeAvailable"),
super::super::codec::Value::Array(items),
);
}
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_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_who: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_communication_method: Option<&super::super::codec::Value> = None;
let mut raw_validation_status: Option<&super::super::codec::Value> = None;
let mut raw_validation_date: Option<&super::super::codec::Value> = None;
let mut raw_validation_date_element: Option<&super::super::codec::Value> = None;
let mut raw_can_push_updates: Option<&super::super::codec::Value> = None;
let mut raw_push_type_available: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"who" => {
raw_who = Some(value);
}
"type" => {
raw_type = Some(value);
}
"communicationMethod" => {
raw_communication_method = Some(value);
}
"validationStatus" => {
raw_validation_status = Some(value);
}
"validationDate" => {
raw_validation_date = Some(value);
}
"_validationDate" => {
raw_validation_date_element = Some(value);
}
"canPushUpdates" => {
raw_can_push_updates = Some(value);
}
"pushTypeAvailable" => {
raw_push_type_available = Some(value);
}
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_string(
super::super::codec::expect_string(value, path)?,
path,
)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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 field_who = raw_who
.map(|value| {
path.with("who", |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_type = Vec::new();
if let Some(raw) = raw_type {
for (index, value) in path
.with("type", |path| super::super::codec::expect_array(raw, path))?
.iter()
.enumerate()
{
field_type.push(path.with_index("type", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_communication_method = Vec::new();
if let Some(raw) = raw_communication_method {
for (index, value) in path
.with("communicationMethod", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_communication_method.push(path.with_index(
"communicationMethod",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
let field_validation_status = raw_validation_status
.map(|value| {
path.with("validationStatus", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_validation_date = match (raw_validation_date, raw_validation_date_element) {
(None, None) => None,
(value, element) => Some(path.with("validationDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_can_push_updates = raw_can_push_updates
.map(|value| {
path.with("canPushUpdates", |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_push_type_available = Vec::new();
if let Some(raw) = raw_push_type_available {
for (index, value) in path
.with("pushTypeAvailable", |path| {
super::super::codec::expect_array(raw, path)
})?
.iter()
.enumerate()
{
field_push_type_available.push(path.with_index(
"pushTypeAvailable",
index,
|path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
},
)?);
}
}
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
who: field_who,
r#type: field_type,
communication_method: field_communication_method,
validation_status: field_validation_status,
validation_date: field_validation_date,
can_push_updates: field_can_push_updates,
push_type_available: field_push_type_available,
})
}
}
impl serde::Serialize for VerificationResultPrimarySource {
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.validation_date {
super::super::codec::element_entry(&mut map, "_validationDate", item)?;
}
if let Some(item) = &self.can_push_updates {
serde::ser::SerializeMap::serialize_entry(&mut map, "canPushUpdates", item)?;
}
if !self.communication_method.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"communicationMethod",
&self.communication_method,
)?;
}
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.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.push_type_available.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"pushTypeAvailable",
&self.push_type_available,
)?;
}
if !self.r#type.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "type", &self.r#type)?;
}
if let Some(item) = &self.validation_date {
super::super::codec::value_entry(&mut map, "validationDate", item)?;
}
if let Some(item) = &self.validation_status {
serde::ser::SerializeMap::serialize_entry(&mut map, "validationStatus", item)?;
}
if let Some(item) = &self.who {
serde::ser::SerializeMap::serialize_entry(&mut map, "who", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for VerificationResultPrimarySource {
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("VerificationResultPrimarySource");
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, Default, PartialEq, Eq)]
pub struct VerificationResultValidator {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub organization: super::reference::Reference,
pub identity_certificate: Option<super::primitives::String>,
pub attestation_signature: Option<super::signature::Signature>,
}
impl super::super::codec::Json for VerificationResultValidator {
fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
let mut object = super::super::codec::Object::new();
if let Some(v) = &self.id {
object.insert(
std::string::String::from("id"),
super::super::codec::Value::String(v.clone()),
);
}
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),
);
}
object.insert(
std::string::String::from("organization"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(
&self.organization,
)?),
);
if let Some(item) = &self.identity_certificate {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("identityCertificate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_identityCertificate"), e);
}
}
if let Some(item) = &self.attestation_signature {
object.insert(
std::string::String::from("attestationSignature"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
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_extension: Option<&super::super::codec::Value> = None;
let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
let mut raw_organization: Option<&super::super::codec::Value> = None;
let mut raw_identity_certificate: Option<&super::super::codec::Value> = None;
let mut raw_identity_certificate_element: Option<&super::super::codec::Value> = None;
let mut raw_attestation_signature: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"id" => {
raw_id = Some(value);
}
"extension" => {
raw_extension = Some(value);
}
"modifierExtension" => {
raw_modifier_extension = Some(value);
}
"organization" => {
raw_organization = Some(value);
}
"identityCertificate" => {
raw_identity_certificate = Some(value);
}
"_identityCertificate" => {
raw_identity_certificate_element = Some(value);
}
"attestationSignature" => {
raw_attestation_signature = Some(value);
}
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_string(
super::super::codec::expect_string(value, path)?,
path,
)
})
})
.transpose()?;
let mut field_extension = Vec::new();
if let Some(raw) = raw_extension {
for (index, value) in path
.with("extension", |path| {
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 path
.with("modifierExtension", |path| {
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 field_organization = path.with("organization", |path| {
let value = raw_organization
.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_identity_certificate =
match (raw_identity_certificate, raw_identity_certificate_element) {
(None, None) => None,
(value, element) => Some(path.with("identityCertificate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_attestation_signature = raw_attestation_signature
.map(|value| {
path.with("attestationSignature", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
organization: field_organization,
identity_certificate: field_identity_certificate,
attestation_signature: field_attestation_signature,
})
}
}
impl serde::Serialize for VerificationResultValidator {
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.identity_certificate {
super::super::codec::element_entry(&mut map, "_identityCertificate", item)?;
}
if let Some(item) = &self.attestation_signature {
serde::ser::SerializeMap::serialize_entry(&mut map, "attestationSignature", item)?;
}
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 let Some(item) = &self.identity_certificate {
super::super::codec::value_entry(&mut map, "identityCertificate", 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, "organization", &self.organization)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for VerificationResultValidator {
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("VerificationResultValidator");
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)
}
}