#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct CapabilityStatement {
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 url: Option<super::primitives::Uri>,
pub version: Option<super::primitives::String>,
pub name: Option<super::primitives::String>,
pub title: Option<super::primitives::String>,
pub status: super::primitives::Code,
pub experimental: Option<super::primitives::Boolean>,
pub date: super::primitives::DateTime,
pub publisher: Option<super::primitives::String>,
pub contact: Vec<super::contact_detail::ContactDetail>,
pub description: Option<super::primitives::Markdown>,
pub use_context: Vec<super::usage_context::UsageContext>,
pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
pub purpose: Option<super::primitives::Markdown>,
pub copyright: Option<super::primitives::Markdown>,
pub kind: super::primitives::Code,
pub instantiates: Vec<super::primitives::Canonical>,
pub imports: Vec<super::primitives::Canonical>,
pub software: Option<CapabilityStatementSoftware>,
pub implementation: Option<CapabilityStatementImplementation>,
pub fhir_version: super::primitives::Code,
pub format: Vec<super::primitives::Code>,
pub patch_format: Vec<super::primitives::Code>,
pub implementation_guide: Vec<super::primitives::Canonical>,
pub rest: Vec<CapabilityStatementRest>,
pub messaging: Vec<CapabilityStatementMessaging>,
pub document: Vec<CapabilityStatementDocument>,
}
impl super::super::codec::Json for CapabilityStatement {
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("CapabilityStatement")),
);
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 let Some(item) = &self.url {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("url"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_url"), e);
}
}
if let Some(item) = &self.version {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("version"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_version"), e);
}
}
if let Some(item) = &self.name {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_name"), e);
}
}
if let Some(item) = &self.title {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("title"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_title"), e);
}
}
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.experimental {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("experimental"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_experimental"), e);
}
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.date)? {
object.insert(std::string::String::from("date"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.date)? {
object.insert(std::string::String::from("_date"), e);
}
if let Some(item) = &self.publisher {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("publisher"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_publisher"), e);
}
}
if !self.contact.is_empty() {
let mut items = Vec::with_capacity(self.contact.len());
for item in &self.contact {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("contact"),
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 !self.use_context.is_empty() {
let mut items = Vec::with_capacity(self.use_context.len());
for item in &self.use_context {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("useContext"),
super::super::codec::Value::Array(items),
);
}
if !self.jurisdiction.is_empty() {
let mut items = Vec::with_capacity(self.jurisdiction.len());
for item in &self.jurisdiction {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("jurisdiction"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.purpose {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("purpose"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_purpose"), e);
}
}
if let Some(item) = &self.copyright {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("copyright"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_copyright"), e);
}
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.kind)? {
object.insert(std::string::String::from("kind"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.kind)? {
object.insert(std::string::String::from("_kind"), e);
}
if !self.instantiates.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.instantiates)?;
object.insert(std::string::String::from("instantiates"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_instantiates"), elements);
}
}
if !self.imports.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.imports)?;
object.insert(std::string::String::from("imports"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_imports"), elements);
}
}
if let Some(item) = &self.software {
object.insert(
std::string::String::from("software"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(item) = &self.implementation {
object.insert(
std::string::String::from("implementation"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.fhir_version)? {
object.insert(std::string::String::from("fhirVersion"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.fhir_version)? {
object.insert(std::string::String::from("_fhirVersion"), e);
}
if !self.format.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.format)?;
object.insert(std::string::String::from("format"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_format"), elements);
}
}
if !self.patch_format.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.patch_format)?;
object.insert(std::string::String::from("patchFormat"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_patchFormat"), elements);
}
}
if !self.implementation_guide.is_empty() {
let (values, elements) =
super::super::codec::primitive_arrays(&self.implementation_guide)?;
object.insert(std::string::String::from("implementationGuide"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_implementationGuide"), elements);
}
}
if !self.rest.is_empty() {
let mut items = Vec::with_capacity(self.rest.len());
for item in &self.rest {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("rest"),
super::super::codec::Value::Array(items),
);
}
if !self.messaging.is_empty() {
let mut items = Vec::with_capacity(self.messaging.len());
for item in &self.messaging {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("messaging"),
super::super::codec::Value::Array(items),
);
}
if !self.document.is_empty() {
let mut items = Vec::with_capacity(self.document.len());
for item in &self.document {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("document"),
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_url: Option<&super::super::codec::Value> = None;
let mut raw_url_element: Option<&super::super::codec::Value> = None;
let mut raw_version: Option<&super::super::codec::Value> = None;
let mut raw_version_element: Option<&super::super::codec::Value> = None;
let mut raw_name: Option<&super::super::codec::Value> = None;
let mut raw_name_element: Option<&super::super::codec::Value> = None;
let mut raw_title: Option<&super::super::codec::Value> = None;
let mut raw_title_element: 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_experimental: Option<&super::super::codec::Value> = None;
let mut raw_experimental_element: 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_publisher: Option<&super::super::codec::Value> = None;
let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
let mut raw_contact: 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_use_context: Option<&super::super::codec::Value> = None;
let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
let mut raw_purpose: Option<&super::super::codec::Value> = None;
let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
let mut raw_copyright: Option<&super::super::codec::Value> = None;
let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
let mut raw_kind: Option<&super::super::codec::Value> = None;
let mut raw_kind_element: Option<&super::super::codec::Value> = None;
let mut raw_instantiates: Option<&super::super::codec::Value> = None;
let mut raw_instantiates_element: Option<&super::super::codec::Value> = None;
let mut raw_imports: Option<&super::super::codec::Value> = None;
let mut raw_imports_element: Option<&super::super::codec::Value> = None;
let mut raw_software: Option<&super::super::codec::Value> = None;
let mut raw_implementation: Option<&super::super::codec::Value> = None;
let mut raw_fhir_version: Option<&super::super::codec::Value> = None;
let mut raw_fhir_version_element: Option<&super::super::codec::Value> = None;
let mut raw_format: Option<&super::super::codec::Value> = None;
let mut raw_format_element: Option<&super::super::codec::Value> = None;
let mut raw_patch_format: Option<&super::super::codec::Value> = None;
let mut raw_patch_format_element: Option<&super::super::codec::Value> = None;
let mut raw_implementation_guide: Option<&super::super::codec::Value> = None;
let mut raw_implementation_guide_element: Option<&super::super::codec::Value> = None;
let mut raw_rest: Option<&super::super::codec::Value> = None;
let mut raw_messaging: Option<&super::super::codec::Value> = None;
let mut raw_document: Option<&super::super::codec::Value> = None;
for (key, value) in object {
match key.as_str() {
"resourceType" => {
if value.as_str() != Some("CapabilityStatement") {
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),
"url" => raw_url = Some(value),
"_url" => raw_url_element = Some(value),
"version" => raw_version = Some(value),
"_version" => raw_version_element = Some(value),
"name" => raw_name = Some(value),
"_name" => raw_name_element = Some(value),
"title" => raw_title = Some(value),
"_title" => raw_title_element = Some(value),
"status" => raw_status = Some(value),
"_status" => raw_status_element = Some(value),
"experimental" => raw_experimental = Some(value),
"_experimental" => raw_experimental_element = Some(value),
"date" => raw_date = Some(value),
"_date" => raw_date_element = Some(value),
"publisher" => raw_publisher = Some(value),
"_publisher" => raw_publisher_element = Some(value),
"contact" => raw_contact = Some(value),
"description" => raw_description = Some(value),
"_description" => raw_description_element = Some(value),
"useContext" => raw_use_context = Some(value),
"jurisdiction" => raw_jurisdiction = Some(value),
"purpose" => raw_purpose = Some(value),
"_purpose" => raw_purpose_element = Some(value),
"copyright" => raw_copyright = Some(value),
"_copyright" => raw_copyright_element = Some(value),
"kind" => raw_kind = Some(value),
"_kind" => raw_kind_element = Some(value),
"instantiates" => raw_instantiates = Some(value),
"_instantiates" => raw_instantiates_element = Some(value),
"imports" => raw_imports = Some(value),
"_imports" => raw_imports_element = Some(value),
"software" => raw_software = Some(value),
"implementation" => raw_implementation = Some(value),
"fhirVersion" => raw_fhir_version = Some(value),
"_fhirVersion" => raw_fhir_version_element = Some(value),
"format" => raw_format = Some(value),
"_format" => raw_format_element = Some(value),
"patchFormat" => raw_patch_format = Some(value),
"_patchFormat" => raw_patch_format_element = Some(value),
"implementationGuide" => raw_implementation_guide = Some(value),
"_implementationGuide" => raw_implementation_guide_element = Some(value),
"rest" => raw_rest = Some(value),
"messaging" => raw_messaging = Some(value),
"document" => raw_document = 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::super::codec::expect_string(value, 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 field_url = match (raw_url, raw_url_element) {
(None, None) => None,
(value, element) => Some(path.with("url", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_version = match (raw_version, raw_version_element) {
(None, None) => None,
(value, element) => Some(path.with("version", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_name = match (raw_name, raw_name_element) {
(None, None) => None,
(value, element) => Some(path.with("name", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_title = match (raw_title, raw_title_element) {
(None, None) => None,
(value, element) => Some(path.with("title", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_status = path.with("status", |path| {
super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
})?;
let field_experimental = match (raw_experimental, raw_experimental_element) {
(None, None) => None,
(value, element) => Some(path.with("experimental", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_date = path.with("date", |path| {
super::super::codec::Primitive::from_json_parts(raw_date, raw_date_element, path)
})?;
let field_publisher = match (raw_publisher, raw_publisher_element) {
(None, None) => None,
(value, element) => Some(path.with("publisher", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_contact = Vec::new();
if let Some(raw) = raw_contact {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_contact.push(path.with_index("contact", 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 mut field_use_context = Vec::new();
if let Some(raw) = raw_use_context {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_use_context.push(path.with_index("useContext", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_jurisdiction = Vec::new();
if let Some(raw) = raw_jurisdiction {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_purpose = match (raw_purpose, raw_purpose_element) {
(None, None) => None,
(value, element) => Some(path.with("purpose", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_copyright = match (raw_copyright, raw_copyright_element) {
(None, None) => None,
(value, element) => Some(path.with("copyright", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_kind = path.with("kind", |path| {
super::super::codec::Primitive::from_json_parts(raw_kind, raw_kind_element, path)
})?;
let mut field_instantiates = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_instantiates, raw_instantiates_element, path)?
.into_iter()
.enumerate()
{
field_instantiates.push(path.with_index("instantiates", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_imports = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_imports, raw_imports_element, path)?
.into_iter()
.enumerate()
{
field_imports.push(path.with_index("imports", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let field_software = raw_software
.map(|value| {
path.with("software", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_implementation = raw_implementation
.map(|value| {
path.with("implementation", |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(
super::super::codec::expect_single(value, path)?,
path,
)?,
path,
)
})
})
.transpose()?;
let field_fhir_version = path.with("fhirVersion", |path| {
super::super::codec::Primitive::from_json_parts(
raw_fhir_version,
raw_fhir_version_element,
path,
)
})?;
let mut field_format = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_format, raw_format_element, path)?
.into_iter()
.enumerate()
{
field_format.push(path.with_index("format", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_patch_format = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_patch_format, raw_patch_format_element, path)?
.into_iter()
.enumerate()
{
field_patch_format.push(path.with_index("patchFormat", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_implementation_guide = Vec::new();
for (index, (value, element)) in super::super::codec::pair_arrays(
raw_implementation_guide,
raw_implementation_guide_element,
path,
)?
.into_iter()
.enumerate()
{
field_implementation_guide.push(path.with_index(
"implementationGuide",
index,
|path| super::super::codec::Primitive::from_json_parts(value, element, path),
)?);
}
let mut field_rest = Vec::new();
if let Some(raw) = raw_rest {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_rest.push(path.with_index("rest", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_messaging = Vec::new();
if let Some(raw) = raw_messaging {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_messaging.push(path.with_index("messaging", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_document = Vec::new();
if let Some(raw) = raw_document {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_document.push(path.with_index("document", 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,
url: field_url,
version: field_version,
name: field_name,
title: field_title,
status: field_status,
experimental: field_experimental,
date: field_date,
publisher: field_publisher,
contact: field_contact,
description: field_description,
use_context: field_use_context,
jurisdiction: field_jurisdiction,
purpose: field_purpose,
copyright: field_copyright,
kind: field_kind,
instantiates: field_instantiates,
imports: field_imports,
software: field_software,
implementation: field_implementation,
fhir_version: field_fhir_version,
format: field_format,
patch_format: field_patch_format,
implementation_guide: field_implementation_guide,
rest: field_rest,
messaging: field_messaging,
document: field_document,
})
}
}
impl serde::Serialize for CapabilityStatement {
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.copyright {
super::super::codec::element_entry(&mut map, "_copyright", item)?;
}
super::super::codec::element_entry(&mut map, "_date", &self.date)?;
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.experimental {
super::super::codec::element_entry(&mut map, "_experimental", item)?;
}
super::super::codec::element_entry(&mut map, "_fhirVersion", &self.fhir_version)?;
super::super::codec::element_list_entry(&mut map, "_format", &self.format)?;
super::super::codec::element_list_entry(
&mut map,
"_implementationGuide",
&self.implementation_guide,
)?;
if let Some(item) = &self.implicit_rules {
super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
}
super::super::codec::element_list_entry(&mut map, "_imports", &self.imports)?;
super::super::codec::element_list_entry(&mut map, "_instantiates", &self.instantiates)?;
super::super::codec::element_entry(&mut map, "_kind", &self.kind)?;
if let Some(item) = &self.language {
super::super::codec::element_entry(&mut map, "_language", item)?;
}
if let Some(item) = &self.name {
super::super::codec::element_entry(&mut map, "_name", item)?;
}
super::super::codec::element_list_entry(&mut map, "_patchFormat", &self.patch_format)?;
if let Some(item) = &self.publisher {
super::super::codec::element_entry(&mut map, "_publisher", item)?;
}
if let Some(item) = &self.purpose {
super::super::codec::element_entry(&mut map, "_purpose", item)?;
}
super::super::codec::element_entry(&mut map, "_status", &self.status)?;
if let Some(item) = &self.title {
super::super::codec::element_entry(&mut map, "_title", item)?;
}
if let Some(item) = &self.url {
super::super::codec::element_entry(&mut map, "_url", item)?;
}
if let Some(item) = &self.version {
super::super::codec::element_entry(&mut map, "_version", item)?;
}
if !self.contact.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
}
if !self.contained.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
}
if let Some(item) = &self.copyright {
super::super::codec::value_entry(&mut map, "copyright", item)?;
}
super::super::codec::value_entry(&mut map, "date", &self.date)?;
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", item)?;
}
if !self.document.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "document", &self.document)?;
}
if let Some(item) = &self.experimental {
super::super::codec::value_entry(&mut map, "experimental", item)?;
}
if !self.extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
}
super::super::codec::value_entry(&mut map, "fhirVersion", &self.fhir_version)?;
super::super::codec::value_list_entry(&mut map, "format", &self.format)?;
if let Some(v) = &self.id {
serde::ser::SerializeMap::serialize_entry(&mut map, "id", v)?;
}
if let Some(item) = &self.implementation {
serde::ser::SerializeMap::serialize_entry(&mut map, "implementation", item)?;
}
super::super::codec::value_list_entry(
&mut map,
"implementationGuide",
&self.implementation_guide,
)?;
if let Some(item) = &self.implicit_rules {
super::super::codec::value_entry(&mut map, "implicitRules", item)?;
}
super::super::codec::value_list_entry(&mut map, "imports", &self.imports)?;
super::super::codec::value_list_entry(&mut map, "instantiates", &self.instantiates)?;
if !self.jurisdiction.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"jurisdiction",
&self.jurisdiction,
)?;
}
super::super::codec::value_entry(&mut map, "kind", &self.kind)?;
if let Some(item) = &self.language {
super::super::codec::value_entry(&mut map, "language", item)?;
}
if !self.messaging.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "messaging", &self.messaging)?;
}
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.name {
super::super::codec::value_entry(&mut map, "name", item)?;
}
super::super::codec::value_list_entry(&mut map, "patchFormat", &self.patch_format)?;
if let Some(item) = &self.publisher {
super::super::codec::value_entry(&mut map, "publisher", item)?;
}
if let Some(item) = &self.purpose {
super::super::codec::value_entry(&mut map, "purpose", item)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "CapabilityStatement")?;
if !self.rest.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "rest", &self.rest)?;
}
if let Some(item) = &self.software {
serde::ser::SerializeMap::serialize_entry(&mut map, "software", item)?;
}
super::super::codec::value_entry(&mut map, "status", &self.status)?;
if let Some(item) = &self.text {
serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
}
if let Some(item) = &self.title {
super::super::codec::value_entry(&mut map, "title", item)?;
}
if let Some(item) = &self.url {
super::super::codec::value_entry(&mut map, "url", item)?;
}
if !self.use_context.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
}
if let Some(item) = &self.version {
super::super::codec::value_entry(&mut map, "version", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatement {
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("CapabilityStatement");
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 CapabilityStatementDocument {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub mode: super::primitives::Code,
pub documentation: Option<super::primitives::Markdown>,
pub profile: super::primitives::Canonical,
}
impl super::super::codec::Json for CapabilityStatementDocument {
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(v) = super::super::codec::Primitive::value_json(&self.mode)? {
object.insert(std::string::String::from("mode"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
object.insert(std::string::String::from("_mode"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.profile)? {
object.insert(std::string::String::from("profile"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.profile)? {
object.insert(std::string::String::from("_profile"), e);
}
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_mode: Option<&super::super::codec::Value> = None;
let mut raw_mode_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
let mut raw_profile: Option<&super::super::codec::Value> = None;
let mut raw_profile_element: 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),
"mode" => raw_mode = Some(value),
"_mode" => raw_mode_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = Some(value),
"profile" => raw_profile = Some(value),
"_profile" => raw_profile_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_mode = path.with("mode", |path| {
super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_profile = path.with("profile", |path| {
super::super::codec::Primitive::from_json_parts(raw_profile, raw_profile_element, path)
})?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
mode: field_mode,
documentation: field_documentation,
profile: field_profile,
})
}
}
impl serde::Serialize for CapabilityStatementDocument {
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.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
super::super::codec::element_entry(&mut map, "_profile", &self.profile)?;
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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)?;
}
super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
super::super::codec::value_entry(&mut map, "profile", &self.profile)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementDocument {
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("CapabilityStatementDocument");
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 CapabilityStatementImplementation {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub description: super::primitives::String,
pub url: Option<super::primitives::Url>,
pub custodian: Option<super::reference::Reference>,
}
impl super::super::codec::Json for CapabilityStatementImplementation {
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(v) = super::super::codec::Primitive::value_json(&self.description)? {
object.insert(std::string::String::from("description"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.description)? {
object.insert(std::string::String::from("_description"), e);
}
if let Some(item) = &self.url {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("url"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_url"), e);
}
}
if let Some(item) = &self.custodian {
object.insert(
std::string::String::from("custodian"),
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_description: Option<&super::super::codec::Value> = None;
let mut raw_description_element: Option<&super::super::codec::Value> = None;
let mut raw_url: Option<&super::super::codec::Value> = None;
let mut raw_url_element: Option<&super::super::codec::Value> = None;
let mut raw_custodian: 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),
"description" => raw_description = Some(value),
"_description" => raw_description_element = Some(value),
"url" => raw_url = Some(value),
"_url" => raw_url_element = Some(value),
"custodian" => raw_custodian = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_description = path.with("description", |path| {
super::super::codec::Primitive::from_json_parts(
raw_description,
raw_description_element,
path,
)
})?;
let field_url = match (raw_url, raw_url_element) {
(None, None) => None,
(value, element) => Some(path.with("url", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_custodian = raw_custodian
.map(|value| {
path.with("custodian", |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,
description: field_description,
url: field_url,
custodian: field_custodian,
})
}
}
impl serde::Serialize for CapabilityStatementImplementation {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_description", &self.description)?;
if let Some(item) = &self.url {
super::super::codec::element_entry(&mut map, "_url", item)?;
}
if let Some(item) = &self.custodian {
serde::ser::SerializeMap::serialize_entry(&mut map, "custodian", item)?;
}
super::super::codec::value_entry(&mut map, "description", &self.description)?;
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.url {
super::super::codec::value_entry(&mut map, "url", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementImplementation {
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("CapabilityStatementImplementation");
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 CapabilityStatementMessaging {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub endpoint: Vec<CapabilityStatementMessagingEndpoint>,
pub reliable_cache: Option<super::primitives::UnsignedInt>,
pub documentation: Option<super::primitives::Markdown>,
pub supported_message: Vec<CapabilityStatementMessagingSupportedMessage>,
}
impl super::super::codec::Json for CapabilityStatementMessaging {
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 !self.endpoint.is_empty() {
let mut items = Vec::with_capacity(self.endpoint.len());
for item in &self.endpoint {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("endpoint"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.reliable_cache {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("reliableCache"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_reliableCache"), e);
}
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
if !self.supported_message.is_empty() {
let mut items = Vec::with_capacity(self.supported_message.len());
for item in &self.supported_message {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("supportedMessage"),
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_endpoint: Option<&super::super::codec::Value> = None;
let mut raw_reliable_cache: Option<&super::super::codec::Value> = None;
let mut raw_reliable_cache_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
let mut raw_supported_message: 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),
"endpoint" => raw_endpoint = Some(value),
"reliableCache" => raw_reliable_cache = Some(value),
"_reliableCache" => raw_reliable_cache_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = Some(value),
"supportedMessage" => raw_supported_message = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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_endpoint = Vec::new();
if let Some(raw) = raw_endpoint {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_endpoint.push(path.with_index("endpoint", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_reliable_cache = match (raw_reliable_cache, raw_reliable_cache_element) {
(None, None) => None,
(value, element) => Some(path.with("reliableCache", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_supported_message = Vec::new();
if let Some(raw) = raw_supported_message {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_supported_message.push(path.with_index(
"supportedMessage",
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,
endpoint: field_endpoint,
reliable_cache: field_reliable_cache,
documentation: field_documentation,
supported_message: field_supported_message,
})
}
}
impl serde::Serialize for CapabilityStatementMessaging {
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.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
if let Some(item) = &self.reliable_cache {
super::super::codec::element_entry(&mut map, "_reliableCache", item)?;
}
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", item)?;
}
if !self.endpoint.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "endpoint", &self.endpoint)?;
}
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.reliable_cache {
super::super::codec::value_entry(&mut map, "reliableCache", item)?;
}
if !self.supported_message.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"supportedMessage",
&self.supported_message,
)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementMessaging {
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("CapabilityStatementMessaging");
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 CapabilityStatementMessagingEndpoint {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub protocol: super::coding::Coding,
pub address: super::primitives::Url,
}
impl super::super::codec::Json for CapabilityStatementMessagingEndpoint {
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("protocol"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(&self.protocol)?),
);
if let Some(v) = super::super::codec::Primitive::value_json(&self.address)? {
object.insert(std::string::String::from("address"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.address)? {
object.insert(std::string::String::from("_address"), e);
}
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_protocol: Option<&super::super::codec::Value> = None;
let mut raw_address: Option<&super::super::codec::Value> = None;
let mut raw_address_element: 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),
"protocol" => raw_protocol = Some(value),
"address" => raw_address = Some(value),
"_address" => raw_address_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_protocol = path.with("protocol", |path| {
let value = raw_protocol
.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_address = path.with("address", |path| {
super::super::codec::Primitive::from_json_parts(raw_address, raw_address_element, path)
})?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
protocol: field_protocol,
address: field_address,
})
}
}
impl serde::Serialize for CapabilityStatementMessagingEndpoint {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_address", &self.address)?;
super::super::codec::value_entry(&mut map, "address", &self.address)?;
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,
)?;
}
serde::ser::SerializeMap::serialize_entry(&mut map, "protocol", &self.protocol)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementMessagingEndpoint {
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("CapabilityStatementMessagingEndpoint");
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 CapabilityStatementMessagingSupportedMessage {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub mode: super::primitives::Code,
pub definition: super::primitives::Canonical,
}
impl super::super::codec::Json for CapabilityStatementMessagingSupportedMessage {
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(v) = super::super::codec::Primitive::value_json(&self.mode)? {
object.insert(std::string::String::from("mode"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
object.insert(std::string::String::from("_mode"), e);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.definition)? {
object.insert(std::string::String::from("definition"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.definition)? {
object.insert(std::string::String::from("_definition"), e);
}
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_mode: Option<&super::super::codec::Value> = None;
let mut raw_mode_element: Option<&super::super::codec::Value> = None;
let mut raw_definition: Option<&super::super::codec::Value> = None;
let mut raw_definition_element: 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),
"mode" => raw_mode = Some(value),
"_mode" => raw_mode_element = Some(value),
"definition" => raw_definition = Some(value),
"_definition" => raw_definition_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_mode = path.with("mode", |path| {
super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
})?;
let field_definition = path.with("definition", |path| {
super::super::codec::Primitive::from_json_parts(
raw_definition,
raw_definition_element,
path,
)
})?;
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
mode: field_mode,
definition: field_definition,
})
}
}
impl serde::Serialize for CapabilityStatementMessagingSupportedMessage {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_definition", &self.definition)?;
super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
super::super::codec::value_entry(&mut map, "definition", &self.definition)?;
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)?;
}
super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementMessagingSupportedMessage {
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("CapabilityStatementMessagingSupportedMessage");
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 CapabilityStatementRest {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub mode: super::primitives::Code,
pub documentation: Option<super::primitives::Markdown>,
pub security: Option<CapabilityStatementRestSecurity>,
pub resource: Vec<CapabilityStatementRestResource>,
pub interaction: Vec<CapabilityStatementRestInteraction>,
pub search_param: Vec<CapabilityStatementRestResourceSearchParam>,
pub operation: Vec<CapabilityStatementRestResourceOperation>,
pub compartment: Vec<super::primitives::Canonical>,
}
impl super::super::codec::Json for CapabilityStatementRest {
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(v) = super::super::codec::Primitive::value_json(&self.mode)? {
object.insert(std::string::String::from("mode"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.mode)? {
object.insert(std::string::String::from("_mode"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
if let Some(item) = &self.security {
object.insert(
std::string::String::from("security"),
super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
);
}
if !self.resource.is_empty() {
let mut items = Vec::with_capacity(self.resource.len());
for item in &self.resource {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("resource"),
super::super::codec::Value::Array(items),
);
}
if !self.interaction.is_empty() {
let mut items = Vec::with_capacity(self.interaction.len());
for item in &self.interaction {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("interaction"),
super::super::codec::Value::Array(items),
);
}
if !self.search_param.is_empty() {
let mut items = Vec::with_capacity(self.search_param.len());
for item in &self.search_param {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("searchParam"),
super::super::codec::Value::Array(items),
);
}
if !self.operation.is_empty() {
let mut items = Vec::with_capacity(self.operation.len());
for item in &self.operation {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("operation"),
super::super::codec::Value::Array(items),
);
}
if !self.compartment.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.compartment)?;
object.insert(std::string::String::from("compartment"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_compartment"), elements);
}
}
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_mode: Option<&super::super::codec::Value> = None;
let mut raw_mode_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
let mut raw_security: Option<&super::super::codec::Value> = None;
let mut raw_resource: Option<&super::super::codec::Value> = None;
let mut raw_interaction: Option<&super::super::codec::Value> = None;
let mut raw_search_param: Option<&super::super::codec::Value> = None;
let mut raw_operation: Option<&super::super::codec::Value> = None;
let mut raw_compartment: Option<&super::super::codec::Value> = None;
let mut raw_compartment_element: 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),
"mode" => raw_mode = Some(value),
"_mode" => raw_mode_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = Some(value),
"security" => raw_security = Some(value),
"resource" => raw_resource = Some(value),
"interaction" => raw_interaction = Some(value),
"searchParam" => raw_search_param = Some(value),
"operation" => raw_operation = Some(value),
"compartment" => raw_compartment = Some(value),
"_compartment" => raw_compartment_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_mode = path.with("mode", |path| {
super::super::codec::Primitive::from_json_parts(raw_mode, raw_mode_element, path)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_security = raw_security
.map(|value| {
path.with("security", |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_resource = Vec::new();
if let Some(raw) = raw_resource {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_resource.push(path.with_index("resource", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_interaction = Vec::new();
if let Some(raw) = raw_interaction {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_interaction.push(path.with_index("interaction", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_search_param = Vec::new();
if let Some(raw) = raw_search_param {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_search_param.push(path.with_index("searchParam", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_operation = Vec::new();
if let Some(raw) = raw_operation {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_operation.push(path.with_index("operation", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_compartment = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_compartment, raw_compartment_element, path)?
.into_iter()
.enumerate()
{
field_compartment.push(path.with_index("compartment", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
mode: field_mode,
documentation: field_documentation,
security: field_security,
resource: field_resource,
interaction: field_interaction,
search_param: field_search_param,
operation: field_operation,
compartment: field_compartment,
})
}
}
impl serde::Serialize for CapabilityStatementRest {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_list_entry(&mut map, "_compartment", &self.compartment)?;
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::element_entry(&mut map, "_mode", &self.mode)?;
super::super::codec::value_list_entry(&mut map, "compartment", &self.compartment)?;
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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.interaction.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "interaction", &self.interaction)?;
}
super::super::codec::value_entry(&mut map, "mode", &self.mode)?;
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.operation.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "operation", &self.operation)?;
}
if !self.resource.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "resource", &self.resource)?;
}
if !self.search_param.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "searchParam", &self.search_param)?;
}
if let Some(item) = &self.security {
serde::ser::SerializeMap::serialize_entry(&mut map, "security", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRest {
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("CapabilityStatementRest");
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 CapabilityStatementRestInteraction {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub code: super::primitives::Code,
pub documentation: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for CapabilityStatementRestInteraction {
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(v) = super::super::codec::Primitive::value_json(&self.code)? {
object.insert(std::string::String::from("code"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
object.insert(std::string::String::from("_code"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
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_code: Option<&super::super::codec::Value> = None;
let mut raw_code_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: 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),
"code" => raw_code = Some(value),
"_code" => raw_code_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_code = path.with("code", |path| {
super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
code: field_code,
documentation: field_documentation,
})
}
}
impl serde::Serialize for CapabilityStatementRestInteraction {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_code", &self.code)?;
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::value_entry(&mut map, "code", &self.code)?;
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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,
)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestInteraction {
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("CapabilityStatementRestInteraction");
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 CapabilityStatementRestResource {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub r#type: super::primitives::Code,
pub profile: Option<super::primitives::Canonical>,
pub supported_profile: Vec<super::primitives::Canonical>,
pub documentation: Option<super::primitives::Markdown>,
pub interaction: Vec<CapabilityStatementRestResourceInteraction>,
pub versioning: Option<super::primitives::Code>,
pub read_history: Option<super::primitives::Boolean>,
pub update_create: Option<super::primitives::Boolean>,
pub conditional_create: Option<super::primitives::Boolean>,
pub conditional_read: Option<super::primitives::Code>,
pub conditional_update: Option<super::primitives::Boolean>,
pub conditional_delete: Option<super::primitives::Code>,
pub reference_policy: Vec<super::primitives::Code>,
pub search_include: Vec<super::primitives::String>,
pub search_rev_include: Vec<super::primitives::String>,
pub search_param: Vec<CapabilityStatementRestResourceSearchParam>,
pub operation: Vec<CapabilityStatementRestResourceOperation>,
}
impl super::super::codec::Json for CapabilityStatementRestResource {
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(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
object.insert(std::string::String::from("type"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
object.insert(std::string::String::from("_type"), e);
}
if let Some(item) = &self.profile {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("profile"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_profile"), e);
}
}
if !self.supported_profile.is_empty() {
let (values, elements) =
super::super::codec::primitive_arrays(&self.supported_profile)?;
object.insert(std::string::String::from("supportedProfile"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_supportedProfile"), elements);
}
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
if !self.interaction.is_empty() {
let mut items = Vec::with_capacity(self.interaction.len());
for item in &self.interaction {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("interaction"),
super::super::codec::Value::Array(items),
);
}
if let Some(item) = &self.versioning {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("versioning"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_versioning"), e);
}
}
if let Some(item) = &self.read_history {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("readHistory"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_readHistory"), e);
}
}
if let Some(item) = &self.update_create {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("updateCreate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_updateCreate"), e);
}
}
if let Some(item) = &self.conditional_create {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("conditionalCreate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_conditionalCreate"), e);
}
}
if let Some(item) = &self.conditional_read {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("conditionalRead"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_conditionalRead"), e);
}
}
if let Some(item) = &self.conditional_update {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("conditionalUpdate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_conditionalUpdate"), e);
}
}
if let Some(item) = &self.conditional_delete {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("conditionalDelete"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_conditionalDelete"), e);
}
}
if !self.reference_policy.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.reference_policy)?;
object.insert(std::string::String::from("referencePolicy"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_referencePolicy"), elements);
}
}
if !self.search_include.is_empty() {
let (values, elements) = super::super::codec::primitive_arrays(&self.search_include)?;
object.insert(std::string::String::from("searchInclude"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_searchInclude"), elements);
}
}
if !self.search_rev_include.is_empty() {
let (values, elements) =
super::super::codec::primitive_arrays(&self.search_rev_include)?;
object.insert(std::string::String::from("searchRevInclude"), values);
if let Some(elements) = elements {
object.insert(std::string::String::from("_searchRevInclude"), elements);
}
}
if !self.search_param.is_empty() {
let mut items = Vec::with_capacity(self.search_param.len());
for item in &self.search_param {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("searchParam"),
super::super::codec::Value::Array(items),
);
}
if !self.operation.is_empty() {
let mut items = Vec::with_capacity(self.operation.len());
for item in &self.operation {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("operation"),
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_type: Option<&super::super::codec::Value> = None;
let mut raw_type_element: Option<&super::super::codec::Value> = None;
let mut raw_profile: Option<&super::super::codec::Value> = None;
let mut raw_profile_element: Option<&super::super::codec::Value> = None;
let mut raw_supported_profile: Option<&super::super::codec::Value> = None;
let mut raw_supported_profile_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: Option<&super::super::codec::Value> = None;
let mut raw_interaction: Option<&super::super::codec::Value> = None;
let mut raw_versioning: Option<&super::super::codec::Value> = None;
let mut raw_versioning_element: Option<&super::super::codec::Value> = None;
let mut raw_read_history: Option<&super::super::codec::Value> = None;
let mut raw_read_history_element: Option<&super::super::codec::Value> = None;
let mut raw_update_create: Option<&super::super::codec::Value> = None;
let mut raw_update_create_element: Option<&super::super::codec::Value> = None;
let mut raw_conditional_create: Option<&super::super::codec::Value> = None;
let mut raw_conditional_create_element: Option<&super::super::codec::Value> = None;
let mut raw_conditional_read: Option<&super::super::codec::Value> = None;
let mut raw_conditional_read_element: Option<&super::super::codec::Value> = None;
let mut raw_conditional_update: Option<&super::super::codec::Value> = None;
let mut raw_conditional_update_element: Option<&super::super::codec::Value> = None;
let mut raw_conditional_delete: Option<&super::super::codec::Value> = None;
let mut raw_conditional_delete_element: Option<&super::super::codec::Value> = None;
let mut raw_reference_policy: Option<&super::super::codec::Value> = None;
let mut raw_reference_policy_element: Option<&super::super::codec::Value> = None;
let mut raw_search_include: Option<&super::super::codec::Value> = None;
let mut raw_search_include_element: Option<&super::super::codec::Value> = None;
let mut raw_search_rev_include: Option<&super::super::codec::Value> = None;
let mut raw_search_rev_include_element: Option<&super::super::codec::Value> = None;
let mut raw_search_param: Option<&super::super::codec::Value> = None;
let mut raw_operation: 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),
"type" => raw_type = Some(value),
"_type" => raw_type_element = Some(value),
"profile" => raw_profile = Some(value),
"_profile" => raw_profile_element = Some(value),
"supportedProfile" => raw_supported_profile = Some(value),
"_supportedProfile" => raw_supported_profile_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = Some(value),
"interaction" => raw_interaction = Some(value),
"versioning" => raw_versioning = Some(value),
"_versioning" => raw_versioning_element = Some(value),
"readHistory" => raw_read_history = Some(value),
"_readHistory" => raw_read_history_element = Some(value),
"updateCreate" => raw_update_create = Some(value),
"_updateCreate" => raw_update_create_element = Some(value),
"conditionalCreate" => raw_conditional_create = Some(value),
"_conditionalCreate" => raw_conditional_create_element = Some(value),
"conditionalRead" => raw_conditional_read = Some(value),
"_conditionalRead" => raw_conditional_read_element = Some(value),
"conditionalUpdate" => raw_conditional_update = Some(value),
"_conditionalUpdate" => raw_conditional_update_element = Some(value),
"conditionalDelete" => raw_conditional_delete = Some(value),
"_conditionalDelete" => raw_conditional_delete_element = Some(value),
"referencePolicy" => raw_reference_policy = Some(value),
"_referencePolicy" => raw_reference_policy_element = Some(value),
"searchInclude" => raw_search_include = Some(value),
"_searchInclude" => raw_search_include_element = Some(value),
"searchRevInclude" => raw_search_rev_include = Some(value),
"_searchRevInclude" => raw_search_rev_include_element = Some(value),
"searchParam" => raw_search_param = Some(value),
"operation" => raw_operation = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_type = path.with("type", |path| {
super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
})?;
let field_profile = match (raw_profile, raw_profile_element) {
(None, None) => None,
(value, element) => Some(path.with("profile", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_supported_profile = Vec::new();
for (index, (value, element)) in super::super::codec::pair_arrays(
raw_supported_profile,
raw_supported_profile_element,
path,
)?
.into_iter()
.enumerate()
{
field_supported_profile.push(path.with_index("supportedProfile", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_interaction = Vec::new();
if let Some(raw) = raw_interaction {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_interaction.push(path.with_index("interaction", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let field_versioning = match (raw_versioning, raw_versioning_element) {
(None, None) => None,
(value, element) => Some(path.with("versioning", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_read_history = match (raw_read_history, raw_read_history_element) {
(None, None) => None,
(value, element) => Some(path.with("readHistory", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_update_create = match (raw_update_create, raw_update_create_element) {
(None, None) => None,
(value, element) => Some(path.with("updateCreate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_conditional_create =
match (raw_conditional_create, raw_conditional_create_element) {
(None, None) => None,
(value, element) => Some(path.with("conditionalCreate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_conditional_read = match (raw_conditional_read, raw_conditional_read_element) {
(None, None) => None,
(value, element) => Some(path.with("conditionalRead", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_conditional_update =
match (raw_conditional_update, raw_conditional_update_element) {
(None, None) => None,
(value, element) => Some(path.with("conditionalUpdate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_conditional_delete =
match (raw_conditional_delete, raw_conditional_delete_element) {
(None, None) => None,
(value, element) => Some(path.with("conditionalDelete", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_reference_policy = Vec::new();
for (index, (value, element)) in super::super::codec::pair_arrays(
raw_reference_policy,
raw_reference_policy_element,
path,
)?
.into_iter()
.enumerate()
{
field_reference_policy.push(path.with_index("referencePolicy", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_search_include = Vec::new();
for (index, (value, element)) in
super::super::codec::pair_arrays(raw_search_include, raw_search_include_element, path)?
.into_iter()
.enumerate()
{
field_search_include.push(path.with_index("searchInclude", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_search_rev_include = Vec::new();
for (index, (value, element)) in super::super::codec::pair_arrays(
raw_search_rev_include,
raw_search_rev_include_element,
path,
)?
.into_iter()
.enumerate()
{
field_search_rev_include.push(path.with_index("searchRevInclude", index, |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?);
}
let mut field_search_param = Vec::new();
if let Some(raw) = raw_search_param {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_search_param.push(path.with_index("searchParam", index, |path| {
super::super::codec::Json::from_json(
super::super::codec::expect_object(value, path)?,
path,
)
})?);
}
}
let mut field_operation = Vec::new();
if let Some(raw) = raw_operation {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_operation.push(path.with_index("operation", 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,
r#type: field_type,
profile: field_profile,
supported_profile: field_supported_profile,
documentation: field_documentation,
interaction: field_interaction,
versioning: field_versioning,
read_history: field_read_history,
update_create: field_update_create,
conditional_create: field_conditional_create,
conditional_read: field_conditional_read,
conditional_update: field_conditional_update,
conditional_delete: field_conditional_delete,
reference_policy: field_reference_policy,
search_include: field_search_include,
search_rev_include: field_search_rev_include,
search_param: field_search_param,
operation: field_operation,
})
}
}
impl serde::Serialize for CapabilityStatementRestResource {
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.conditional_create {
super::super::codec::element_entry(&mut map, "_conditionalCreate", item)?;
}
if let Some(item) = &self.conditional_delete {
super::super::codec::element_entry(&mut map, "_conditionalDelete", item)?;
}
if let Some(item) = &self.conditional_read {
super::super::codec::element_entry(&mut map, "_conditionalRead", item)?;
}
if let Some(item) = &self.conditional_update {
super::super::codec::element_entry(&mut map, "_conditionalUpdate", item)?;
}
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
if let Some(item) = &self.profile {
super::super::codec::element_entry(&mut map, "_profile", item)?;
}
if let Some(item) = &self.read_history {
super::super::codec::element_entry(&mut map, "_readHistory", item)?;
}
super::super::codec::element_list_entry(
&mut map,
"_referencePolicy",
&self.reference_policy,
)?;
super::super::codec::element_list_entry(&mut map, "_searchInclude", &self.search_include)?;
super::super::codec::element_list_entry(
&mut map,
"_searchRevInclude",
&self.search_rev_include,
)?;
super::super::codec::element_list_entry(
&mut map,
"_supportedProfile",
&self.supported_profile,
)?;
super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
if let Some(item) = &self.update_create {
super::super::codec::element_entry(&mut map, "_updateCreate", item)?;
}
if let Some(item) = &self.versioning {
super::super::codec::element_entry(&mut map, "_versioning", item)?;
}
if let Some(item) = &self.conditional_create {
super::super::codec::value_entry(&mut map, "conditionalCreate", item)?;
}
if let Some(item) = &self.conditional_delete {
super::super::codec::value_entry(&mut map, "conditionalDelete", item)?;
}
if let Some(item) = &self.conditional_read {
super::super::codec::value_entry(&mut map, "conditionalRead", item)?;
}
if let Some(item) = &self.conditional_update {
super::super::codec::value_entry(&mut map, "conditionalUpdate", item)?;
}
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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.interaction.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "interaction", &self.interaction)?;
}
if !self.modifier_extension.is_empty() {
serde::ser::SerializeMap::serialize_entry(
&mut map,
"modifierExtension",
&self.modifier_extension,
)?;
}
if !self.operation.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "operation", &self.operation)?;
}
if let Some(item) = &self.profile {
super::super::codec::value_entry(&mut map, "profile", item)?;
}
if let Some(item) = &self.read_history {
super::super::codec::value_entry(&mut map, "readHistory", item)?;
}
super::super::codec::value_list_entry(&mut map, "referencePolicy", &self.reference_policy)?;
super::super::codec::value_list_entry(&mut map, "searchInclude", &self.search_include)?;
if !self.search_param.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "searchParam", &self.search_param)?;
}
super::super::codec::value_list_entry(
&mut map,
"searchRevInclude",
&self.search_rev_include,
)?;
super::super::codec::value_list_entry(
&mut map,
"supportedProfile",
&self.supported_profile,
)?;
super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
if let Some(item) = &self.update_create {
super::super::codec::value_entry(&mut map, "updateCreate", item)?;
}
if let Some(item) = &self.versioning {
super::super::codec::value_entry(&mut map, "versioning", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResource {
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("CapabilityStatementRestResource");
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 CapabilityStatementRestResourceInteraction {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub code: super::primitives::Code,
pub documentation: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for CapabilityStatementRestResourceInteraction {
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(v) = super::super::codec::Primitive::value_json(&self.code)? {
object.insert(std::string::String::from("code"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.code)? {
object.insert(std::string::String::from("_code"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
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_code: Option<&super::super::codec::Value> = None;
let mut raw_code_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: 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),
"code" => raw_code = Some(value),
"_code" => raw_code_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_code = path.with("code", |path| {
super::super::codec::Primitive::from_json_parts(raw_code, raw_code_element, path)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
code: field_code,
documentation: field_documentation,
})
}
}
impl serde::Serialize for CapabilityStatementRestResourceInteraction {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_code", &self.code)?;
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::value_entry(&mut map, "code", &self.code)?;
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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,
)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceInteraction {
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("CapabilityStatementRestResourceInteraction");
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 CapabilityStatementRestResourceOperation {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub name: super::primitives::String,
pub definition: super::primitives::Canonical,
pub documentation: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for CapabilityStatementRestResourceOperation {
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(v) = super::super::codec::Primitive::value_json(&self.name)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
object.insert(std::string::String::from("_name"), e);
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.definition)? {
object.insert(std::string::String::from("definition"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.definition)? {
object.insert(std::string::String::from("_definition"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
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_name: Option<&super::super::codec::Value> = None;
let mut raw_name_element: Option<&super::super::codec::Value> = None;
let mut raw_definition: Option<&super::super::codec::Value> = None;
let mut raw_definition_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: 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),
"name" => raw_name = Some(value),
"_name" => raw_name_element = Some(value),
"definition" => raw_definition = Some(value),
"_definition" => raw_definition_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_name = path.with("name", |path| {
super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
})?;
let field_definition = path.with("definition", |path| {
super::super::codec::Primitive::from_json_parts(
raw_definition,
raw_definition_element,
path,
)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
name: field_name,
definition: field_definition,
documentation: field_documentation,
})
}
}
impl serde::Serialize for CapabilityStatementRestResourceOperation {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_definition", &self.definition)?;
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::element_entry(&mut map, "_name", &self.name)?;
super::super::codec::value_entry(&mut map, "definition", &self.definition)?;
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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,
)?;
}
super::super::codec::value_entry(&mut map, "name", &self.name)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceOperation {
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("CapabilityStatementRestResourceOperation");
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 CapabilityStatementRestResourceSearchParam {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub name: super::primitives::String,
pub definition: Option<super::primitives::Canonical>,
pub r#type: super::primitives::Code,
pub documentation: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for CapabilityStatementRestResourceSearchParam {
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(v) = super::super::codec::Primitive::value_json(&self.name)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
object.insert(std::string::String::from("_name"), e);
}
if let Some(item) = &self.definition {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("definition"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_definition"), e);
}
}
if let Some(v) = super::super::codec::Primitive::value_json(&self.r#type)? {
object.insert(std::string::String::from("type"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.r#type)? {
object.insert(std::string::String::from("_type"), e);
}
if let Some(item) = &self.documentation {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("documentation"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_documentation"), e);
}
}
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_name: Option<&super::super::codec::Value> = None;
let mut raw_name_element: Option<&super::super::codec::Value> = None;
let mut raw_definition: Option<&super::super::codec::Value> = None;
let mut raw_definition_element: Option<&super::super::codec::Value> = None;
let mut raw_type: Option<&super::super::codec::Value> = None;
let mut raw_type_element: Option<&super::super::codec::Value> = None;
let mut raw_documentation: Option<&super::super::codec::Value> = None;
let mut raw_documentation_element: 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),
"name" => raw_name = Some(value),
"_name" => raw_name_element = Some(value),
"definition" => raw_definition = Some(value),
"_definition" => raw_definition_element = Some(value),
"type" => raw_type = Some(value),
"_type" => raw_type_element = Some(value),
"documentation" => raw_documentation = Some(value),
"_documentation" => raw_documentation_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_name = path.with("name", |path| {
super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
})?;
let field_definition = match (raw_definition, raw_definition_element) {
(None, None) => None,
(value, element) => Some(path.with("definition", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_type = path.with("type", |path| {
super::super::codec::Primitive::from_json_parts(raw_type, raw_type_element, path)
})?;
let field_documentation = match (raw_documentation, raw_documentation_element) {
(None, None) => None,
(value, element) => Some(path.with("documentation", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
name: field_name,
definition: field_definition,
r#type: field_type,
documentation: field_documentation,
})
}
}
impl serde::Serialize for CapabilityStatementRestResourceSearchParam {
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.definition {
super::super::codec::element_entry(&mut map, "_definition", item)?;
}
if let Some(item) = &self.documentation {
super::super::codec::element_entry(&mut map, "_documentation", item)?;
}
super::super::codec::element_entry(&mut map, "_name", &self.name)?;
super::super::codec::element_entry(&mut map, "_type", &self.r#type)?;
if let Some(item) = &self.definition {
super::super::codec::value_entry(&mut map, "definition", item)?;
}
if let Some(item) = &self.documentation {
super::super::codec::value_entry(&mut map, "documentation", 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,
)?;
}
super::super::codec::value_entry(&mut map, "name", &self.name)?;
super::super::codec::value_entry(&mut map, "type", &self.r#type)?;
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestResourceSearchParam {
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("CapabilityStatementRestResourceSearchParam");
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 CapabilityStatementRestSecurity {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub cors: Option<super::primitives::Boolean>,
pub service: Vec<super::codeable_concept::CodeableConcept>,
pub description: Option<super::primitives::Markdown>,
}
impl super::super::codec::Json for CapabilityStatementRestSecurity {
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.cors {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("cors"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_cors"), e);
}
}
if !self.service.is_empty() {
let mut items = Vec::with_capacity(self.service.len());
for item in &self.service {
items.push(super::super::codec::Value::Object(
super::super::codec::Json::to_json(item)?,
));
}
object.insert(
std::string::String::from("service"),
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);
}
}
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_cors: Option<&super::super::codec::Value> = None;
let mut raw_cors_element: Option<&super::super::codec::Value> = None;
let mut raw_service: 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;
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),
"cors" => raw_cors = Some(value),
"_cors" => raw_cors_element = Some(value),
"service" => raw_service = Some(value),
"description" => raw_description = Some(value),
"_description" => raw_description_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_cors = match (raw_cors, raw_cors_element) {
(None, None) => None,
(value, element) => Some(path.with("cors", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let mut field_service = Vec::new();
if let Some(raw) = raw_service {
for (index, value) in super::super::codec::expect_array(raw, path)?
.iter()
.enumerate()
{
field_service.push(path.with_index("service", 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)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
cors: field_cors,
service: field_service,
description: field_description,
})
}
}
impl serde::Serialize for CapabilityStatementRestSecurity {
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.cors {
super::super::codec::element_entry(&mut map, "_cors", item)?;
}
if let Some(item) = &self.description {
super::super::codec::element_entry(&mut map, "_description", item)?;
}
if let Some(item) = &self.cors {
super::super::codec::value_entry(&mut map, "cors", item)?;
}
if let Some(item) = &self.description {
super::super::codec::value_entry(&mut map, "description", 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 !self.service.is_empty() {
serde::ser::SerializeMap::serialize_entry(&mut map, "service", &self.service)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementRestSecurity {
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("CapabilityStatementRestSecurity");
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 CapabilityStatementSoftware {
pub id: Option<std::string::String>,
pub extension: Vec<super::extension::Extension>,
pub modifier_extension: Vec<super::extension::Extension>,
pub name: super::primitives::String,
pub version: Option<super::primitives::String>,
pub release_date: Option<super::primitives::DateTime>,
}
impl super::super::codec::Json for CapabilityStatementSoftware {
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(v) = super::super::codec::Primitive::value_json(&self.name)? {
object.insert(std::string::String::from("name"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(&self.name)? {
object.insert(std::string::String::from("_name"), e);
}
if let Some(item) = &self.version {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("version"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_version"), e);
}
}
if let Some(item) = &self.release_date {
if let Some(v) = super::super::codec::Primitive::value_json(item)? {
object.insert(std::string::String::from("releaseDate"), v);
}
if let Some(e) = super::super::codec::Primitive::element_json(item)? {
object.insert(std::string::String::from("_releaseDate"), e);
}
}
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_name: Option<&super::super::codec::Value> = None;
let mut raw_name_element: Option<&super::super::codec::Value> = None;
let mut raw_version: Option<&super::super::codec::Value> = None;
let mut raw_version_element: Option<&super::super::codec::Value> = None;
let mut raw_release_date: Option<&super::super::codec::Value> = None;
let mut raw_release_date_element: 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),
"name" => raw_name = Some(value),
"_name" => raw_name_element = Some(value),
"version" => raw_version = Some(value),
"_version" => raw_version_element = Some(value),
"releaseDate" => raw_release_date = Some(value),
"_releaseDate" => raw_release_date_element = 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::super::codec::expect_string(value, path)
})
})
.transpose()?;
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 field_name = path.with("name", |path| {
super::super::codec::Primitive::from_json_parts(raw_name, raw_name_element, path)
})?;
let field_version = match (raw_version, raw_version_element) {
(None, None) => None,
(value, element) => Some(path.with("version", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
let field_release_date = match (raw_release_date, raw_release_date_element) {
(None, None) => None,
(value, element) => Some(path.with("releaseDate", |path| {
super::super::codec::Primitive::from_json_parts(value, element, path)
})?),
};
Ok(Self {
id: field_id,
extension: field_extension,
modifier_extension: field_modifier_extension,
name: field_name,
version: field_version,
release_date: field_release_date,
})
}
}
impl serde::Serialize for CapabilityStatementSoftware {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let mut map = serde::Serializer::serialize_map(serializer, None)?;
super::super::codec::element_entry(&mut map, "_name", &self.name)?;
if let Some(item) = &self.release_date {
super::super::codec::element_entry(&mut map, "_releaseDate", item)?;
}
if let Some(item) = &self.version {
super::super::codec::element_entry(&mut map, "_version", 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,
)?;
}
super::super::codec::value_entry(&mut map, "name", &self.name)?;
if let Some(item) = &self.release_date {
super::super::codec::value_entry(&mut map, "releaseDate", item)?;
}
if let Some(item) = &self.version {
super::super::codec::value_entry(&mut map, "version", item)?;
}
serde::ser::SerializeMap::end(map)
}
}
impl<'de> serde::Deserialize<'de> for CapabilityStatementSoftware {
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("CapabilityStatementSoftware");
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)
}
}