// @generated by `cargo xtask codegen` from the DATEX II 3.7 schemas. Do not edit.
//! Types of the DATEX II namespace `http://datex2.eu/schema/3/exchangeInformation`.
//!
//! Names follow the standard; see <https://docs.datex2.eu/> for what each one means.
#[allow(unused_imports)]
use super::{common as com, common_extension as comx, location_referencing as loc, location_extension as locx, situation as sit, road_traffic_data as roa, vms, parking as prk, energy_infrastructure as egi, afir_energy_infrastructure as aegi, facilities as fac, afir_facilities as afac, traffic_regulation as tro, controlled_zone as cz, traffic_management_plan as tmp, rerouting_management_enhanced as rer, urban_extensions as ubx, fault_and_status as fst, message_container as con, information_management as inf, cis_information as cis};
#[allow(unused_imports)]
use crate::out::{Out, Pattern, Rules};
#[allow(unused_imports)]
use crate::json::{JsonReader, JsonWriter};
#[allow(unused_imports)]
use crate::{ErrorKind, WarningKind};
#[allow(unused_imports)]
use crate::xml::{Enumeration, Xml};
#[allow(unused_imports)]
use crate::{Date, DateTime, Decimal, Error, Extension, MultilingualString, Time};
/// XML enumeration `ex:ExchangeReturnEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ExchangeReturnEnum {
/// `ack`
Ack,
/// `closeSessionRequest`
CloseSessionRequest,
/// `fail`
Fail,
/// `snapshotSynchronisationRequest`
SnapshotSynchronisationRequest,
/// A value outside the standard list.
Extended(String),
}
impl ExchangeReturnEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::Ack => "ack",
Self::CloseSessionRequest => "closeSessionRequest",
Self::Fail => "fail",
Self::SnapshotSynchronisationRequest => "snapshotSynchronisationRequest",
Self::Extended(v) => v,
}
}
}
impl Enumeration for ExchangeReturnEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"ack" => Some(Self::Ack),
"closeSessionRequest" => Some(Self::CloseSessionRequest),
"fail" => Some(Self::Fail),
"snapshotSynchronisationRequest" => Some(Self::SnapshotSynchronisationRequest),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl ExchangeReturnEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:ExchangeStatusEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ExchangeStatusEnum {
/// `closingSession`
ClosingSession,
/// `offline`
Offline,
/// `online`
Online,
/// `openingSession`
OpeningSession,
/// `resuming`
Resuming,
/// `undefined`
Undefined,
/// A value outside the standard list.
Extended(String),
}
impl ExchangeStatusEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::ClosingSession => "closingSession",
Self::Offline => "offline",
Self::Online => "online",
Self::OpeningSession => "openingSession",
Self::Resuming => "resuming",
Self::Undefined => "undefined",
Self::Extended(v) => v,
}
}
}
impl Enumeration for ExchangeStatusEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"closingSession" => Some(Self::ClosingSession),
"offline" => Some(Self::Offline),
"online" => Some(Self::Online),
"openingSession" => Some(Self::OpeningSession),
"resuming" => Some(Self::Resuming),
"undefined" => Some(Self::Undefined),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl ExchangeStatusEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:InvalidityReasonEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InvalidityReasonEnum {
/// `invalidCISInformation`
InvalidCISInformation,
/// `invalidExchangeContext`
InvalidExchangeContext,
/// `invalidInformationManagement`
InvalidInformationManagement,
/// `invalidMessage`
InvalidMessage,
/// `invalidPayload`
InvalidPayload,
/// `invalidSequencingNumber`
InvalidSequencingNumber,
/// `invalidSession`
InvalidSession,
/// `other`
Other,
/// `invalidClient`
InvalidClient,
/// `invalidSupplier`
InvalidSupplier,
/// A value outside the standard list.
Extended(String),
}
impl InvalidityReasonEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::InvalidCISInformation => "invalidCISInformation",
Self::InvalidExchangeContext => "invalidExchangeContext",
Self::InvalidInformationManagement => "invalidInformationManagement",
Self::InvalidMessage => "invalidMessage",
Self::InvalidPayload => "invalidPayload",
Self::InvalidSequencingNumber => "invalidSequencingNumber",
Self::InvalidSession => "invalidSession",
Self::Other => "other",
Self::InvalidClient => "invalidClient",
Self::InvalidSupplier => "invalidSupplier",
Self::Extended(v) => v,
}
}
}
impl Enumeration for InvalidityReasonEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"invalidCISInformation" => Some(Self::InvalidCISInformation),
"invalidExchangeContext" => Some(Self::InvalidExchangeContext),
"invalidInformationManagement" => Some(Self::InvalidInformationManagement),
"invalidMessage" => Some(Self::InvalidMessage),
"invalidPayload" => Some(Self::InvalidPayload),
"invalidSequencingNumber" => Some(Self::InvalidSequencingNumber),
"invalidSession" => Some(Self::InvalidSession),
"other" => Some(Self::Other),
"invalidClient" => Some(Self::InvalidClient),
"invalidSupplier" => Some(Self::InvalidSupplier),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl InvalidityReasonEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:MessageTypeEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MessageTypeEnum {
/// `payloadDelivery`
PayloadDelivery,
/// `openSession`
OpenSession,
/// `keepAlive`
KeepAlive,
/// `closeSession`
CloseSession,
/// `return`
Return,
/// `CISServiceRequest`
CISServiceRequest,
/// `CISFeedback`
CISFeedback,
/// A value outside the standard list.
Extended(String),
}
impl MessageTypeEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::PayloadDelivery => "payloadDelivery",
Self::OpenSession => "openSession",
Self::KeepAlive => "keepAlive",
Self::CloseSession => "closeSession",
Self::Return => "return",
Self::CISServiceRequest => "CISServiceRequest",
Self::CISFeedback => "CISFeedback",
Self::Extended(v) => v,
}
}
}
impl Enumeration for MessageTypeEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"payloadDelivery" => Some(Self::PayloadDelivery),
"openSession" => Some(Self::OpenSession),
"keepAlive" => Some(Self::KeepAlive),
"closeSession" => Some(Self::CloseSession),
"return" => Some(Self::Return),
"CISServiceRequest" => Some(Self::CISServiceRequest),
"CISFeedback" => Some(Self::CISFeedback),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl MessageTypeEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:OperatingModeEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum OperatingModeEnum {
/// `conditionTriggered`
ConditionTriggered,
/// `onOccurrence`
OnOccurrence,
/// `other`
Other,
/// `periodic`
Periodic,
/// A value outside the standard list.
Extended(String),
}
impl OperatingModeEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::ConditionTriggered => "conditionTriggered",
Self::OnOccurrence => "onOccurrence",
Self::Other => "other",
Self::Periodic => "periodic",
Self::Extended(v) => v,
}
}
}
impl Enumeration for OperatingModeEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"conditionTriggered" => Some(Self::ConditionTriggered),
"onOccurrence" => Some(Self::OnOccurrence),
"other" => Some(Self::Other),
"periodic" => Some(Self::Periodic),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl OperatingModeEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:ProtocolTypeEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ProtocolTypeEnum {
/// `deltaPull`
DeltaPull,
/// `deltaPush`
DeltaPush,
/// `simpleCIS`
SimpleCIS,
/// `simplePush`
SimplePush,
/// `snapshotPull`
SnapshotPull,
/// `snapshotPush`
SnapshotPush,
/// `statefulCIS`
StatefulCIS,
/// `statefulPush`
StatefulPush,
/// `other`
Other,
/// A value outside the standard list.
Extended(String),
}
impl ProtocolTypeEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::DeltaPull => "deltaPull",
Self::DeltaPush => "deltaPush",
Self::SimpleCIS => "simpleCIS",
Self::SimplePush => "simplePush",
Self::SnapshotPull => "snapshotPull",
Self::SnapshotPush => "snapshotPush",
Self::StatefulCIS => "statefulCIS",
Self::StatefulPush => "statefulPush",
Self::Other => "other",
Self::Extended(v) => v,
}
}
}
impl Enumeration for ProtocolTypeEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"deltaPull" => Some(Self::DeltaPull),
"deltaPush" => Some(Self::DeltaPush),
"simpleCIS" => Some(Self::SimpleCIS),
"simplePush" => Some(Self::SimplePush),
"snapshotPull" => Some(Self::SnapshotPull),
"snapshotPush" => Some(Self::SnapshotPush),
"statefulCIS" => Some(Self::StatefulCIS),
"statefulPush" => Some(Self::StatefulPush),
"other" => Some(Self::Other),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl ProtocolTypeEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML enumeration `ex:UpdateMethodEnum`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum UpdateMethodEnum {
/// `allElementUpdate`
AllElementUpdate,
/// `allInformationUpdate`
AllInformationUpdate,
/// `other`
Other,
/// `singleElementUpdate`
SingleElementUpdate,
/// `snapshot`
Snapshot,
/// A value outside the standard list.
Extended(String),
}
impl UpdateMethodEnum {
/// The value as written in a document.
pub fn as_str(&self) -> &str {
match self {
Self::AllElementUpdate => "allElementUpdate",
Self::AllInformationUpdate => "allInformationUpdate",
Self::Other => "other",
Self::SingleElementUpdate => "singleElementUpdate",
Self::Snapshot => "snapshot",
Self::Extended(v) => v,
}
}
}
impl Enumeration for UpdateMethodEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"allElementUpdate" => Some(Self::AllElementUpdate),
"allInformationUpdate" => Some(Self::AllInformationUpdate),
"other" => Some(Self::Other),
"singleElementUpdate" => Some(Self::SingleElementUpdate),
"snapshot" => Some(Self::Snapshot),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl UpdateMethodEnum {
/// The literal to write and, for a value outside the standard list, that value.
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
/// XML type `ex:Agent`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct Agent {
/// XML element `ex:address`.
pub address: Option<String>,
/// XML element `ex:name`.
pub name: Option<String>,
/// XML element `ex:referenceID`.
pub reference_id: Option<String>,
/// XML element `ex:serviceURL`.
pub service_url: Option<String>,
/// XML element `ex:internationalIdentifier`.
pub international_identifier: Option<Box<com::InternationalIdentifier>>,
/// XML element `ex:_agentExtension`.
pub agent_extension: Option<Box<Extension>>,
}
impl Agent {
const FIELDS: &'static [u32] = &[0x906bc, 0x9098b, 0x90b02, 0x90b8a, 0x908ce, 0x90422];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x9001b);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = None;
let mut e4 = None;
let mut e5 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x906bc => { let v = r.string()?; r.set(&mut e0, v, 1724); }
0x9098b => { let v = r.string()?; r.set(&mut e1, v, 2443); }
0x90b02 => { let v = r.string()?; r.set(&mut e2, v, 2818); }
0x90b8a => { let v = r.string()?; r.set(&mut e3, v, 2954); }
0x908ce => { let v = Some(com::InternationalIdentifier::read(r)?); r.set(&mut e4, v.map(Box::new), 2254); }
0x90422 => { let v = r.raw()?; r.set(&mut e5, v.map(Box::new), 1058); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
let v = Self {
address: e0,
name: e1,
reference_id: e2,
service_url: e3,
international_identifier: e4,
agent_extension: e5,
};
r.close();
Ok(v)
}
}
impl Agent {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
if let Some(v) = &self.address { w.max_len("address", "String", v, 1024)?; w.leaf("ex:address", v)?; }
if let Some(v) = &self.name { w.max_len("name", "String", v, 1024)?; w.leaf("ex:name", v)?; }
if let Some(v) = &self.reference_id { w.max_len("referenceID", "String", v, 1024)?; w.leaf("ex:referenceID", v)?; }
if let Some(v) = &self.service_url { w.max_len("serviceURL", "String", v, 1024)?; w.leaf("ex:serviceURL", v)?; }
if let Some(v) = &self.international_identifier { v.write(w, "ex:internationalIdentifier", "", "")?; }
if let Some(v) = &self.agent_extension { w.extension("ex:_agentExtension", v)?; }
w.end(tag)
}
}
impl Agent {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 6];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
let mut f3 = None;
let mut f4 = None;
let mut f5 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
64 => if r.first(&mut seen[0])? { f0 = r.string()?; },
1345 => if r.first(&mut seen[1])? { f1 = r.string()?; },
1818 => if r.first(&mut seen[2])? { f2 = r.string()?; },
2041 => if r.first(&mut seen[3])? { f3 = r.string()?; },
1001 => if r.first(&mut seen[4])? { f4 = com::InternationalIdentifier::read_json(r)?.map(Box::new); },
707 => if r.first(&mut seen[5])? { f5 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
Ok(Self {
address: f0,
name: f1,
reference_id: f2,
service_url: f3,
international_identifier: f4,
agent_extension: f5,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(342)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
if let Some(v) = &self.address {
w.key(64)?;
w.max_len("address", "String", v, 1024)?; w.string(v)?;
}
if let Some(v) = &self.name {
w.key(1345)?;
w.max_len("name", "String", v, 1024)?; w.string(v)?;
}
if let Some(v) = &self.reference_id {
w.key(1818)?;
w.max_len("referenceID", "String", v, 1024)?; w.string(v)?;
}
if let Some(v) = &self.service_url {
w.key(2041)?;
w.max_len("serviceURL", "String", v, 1024)?; w.string(v)?;
}
if let Some(v) = &self.international_identifier {
w.key(1001)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.agent_extension {
w.key(707)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:DynamicInformation`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct DynamicInformation {
/// XML element `ex:exchangeStatus`.
pub exchange_status: Option<ExchangeStatusEnum>,
/// XML element `ex:exchangeStatusDescription`.
pub exchange_status_description: Option<MultilingualString>,
/// XML element `ex:completedPaylod`.
pub completed_paylod: Option<com::Boolean>,
/// XML element `ex:messageSequencingNumber`.
pub message_sequencing_number: Option<com::NonNegativeInteger>,
/// XML element `ex:messageGenerationTimestamp`.
pub message_generation_timestamp: Option<DateTime>,
/// XML element `ex:returnInformation`.
pub return_information: Option<Box<ReturnInformation>>,
/// XML element `ex:sessionInformation`.
pub session_information: Option<Box<SessionInformation>>,
/// XML element `ex:_dynamicInformationExtension`.
pub dynamic_information_extension: Option<Box<Extension>>,
}
impl DynamicInformation {
const FIELDS: &'static [u32] = &[0x9082c, 0x9082d, 0x90758, 0x9096c, 0x90969, 0x90b3b, 0x90b8e, 0x90493];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x9008e);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = None;
let mut e4 = None;
let mut e5 = None;
let mut e6 = None;
let mut e7 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x9082c => { let v = r.enumeration::<ExchangeStatusEnum>()?; r.set(&mut e0, v, 2092); }
0x9082d => { let v = r.multilingual()?; r.set(&mut e1, v, 2093); }
0x90758 => { let v = r.value::<bool>()?; r.set(&mut e2, v, 1880); }
0x9096c => { let v = r.value::<u64>()?; r.set(&mut e3, v, 2412); }
0x90969 => { let v = r.date_time()?; r.set(&mut e4, v, 2409); }
0x90b3b => { let v = Some(ReturnInformation::read(r)?); r.set(&mut e5, v.map(Box::new), 2875); }
0x90b8e => { let v = Some(SessionInformation::read(r)?); r.set(&mut e6, v.map(Box::new), 2958); }
0x90493 => { let v = r.raw()?; r.set(&mut e7, v.map(Box::new), 1171); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 2092);
r.required(&e4, 2409);
let v = Self {
exchange_status: e0,
exchange_status_description: e1,
completed_paylod: e2,
message_sequencing_number: e3,
message_generation_timestamp: e4,
return_information: e5,
session_information: e6,
dynamic_information_extension: e7,
};
r.close();
Ok(v)
}
}
impl DynamicInformation {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
match &self.exchange_status {
Some(v) => { w.enumeration("ex:exchangeStatus", v.literal())?; }
None => return Err(w.missing("ex:exchangeStatus")),
}
if let Some(v) = &self.exchange_status_description { w.multilingual("ex:exchangeStatusDescription", v)?; }
if let Some(v) = &self.completed_paylod { w.leaf("ex:completedPaylod", v)?; }
if let Some(v) = &self.message_sequencing_number { w.leaf("ex:messageSequencingNumber", v)?; }
match &self.message_generation_timestamp {
Some(v) => { w.leaf("ex:messageGenerationTimestamp", v)?; }
None => return Err(w.missing("ex:messageGenerationTimestamp")),
}
if let Some(v) = &self.return_information { v.write(w, "ex:returnInformation", "", "")?; }
if let Some(v) = &self.session_information { v.write(w, "ex:sessionInformation", "", "")?; }
if let Some(v) = &self.dynamic_information_extension { w.extension("ex:_dynamicInformationExtension", v)?; }
w.end(tag)
}
}
impl DynamicInformation {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 8];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
let mut f3 = None;
let mut f4 = None;
let mut f5 = None;
let mut f6 = None;
let mut f7 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
718 => if r.first(&mut seen[0])? { f0 = r.enumeration::<ExchangeStatusEnum>()?; },
719 => if r.first(&mut seen[1])? { f1 = r.multilingual()?; },
422 => if r.first(&mut seen[2])? { f2 = r.boolean()?; },
1314 => if r.first(&mut seen[3])? { f3 = r.number::<u64>()?; },
1311 => if r.first(&mut seen[4])? { f4 = r.date_time()?; },
1898 => if r.first(&mut seen[5])? { f5 = ReturnInformation::read_json(r)?.map(Box::new); },
2045 => if r.first(&mut seen[6])? { f6 = SessionInformation::read_json(r)?.map(Box::new); },
708 => if r.first(&mut seen[7])? { f7 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
r.required(&f0, 718);
r.required(&f4, 1311);
Ok(Self {
exchange_status: f0,
exchange_status_description: f1,
completed_paylod: f2,
message_sequencing_number: f3,
message_generation_timestamp: f4,
return_information: f5,
session_information: f6,
dynamic_information_extension: f7,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(343)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
match &self.exchange_status {
Some(v) => {
w.key(718)?;
w.enumeration(347, v.literal())?;
}
None => w.absent(718, w.missing("exchangeStatus"))?,
}
if let Some(v) = &self.exchange_status_description {
w.key(719)?;
w.multilingual(v)?;
}
if let Some(v) = &self.completed_paylod {
w.key(422)?;
w.boolean(*v)?;
}
if let Some(v) = &self.message_sequencing_number {
w.key(1314)?;
w.integer(*v)?;
}
match &self.message_generation_timestamp {
Some(v) => {
w.key(1311)?;
w.date_time(v)?;
}
None => w.absent(1311, w.missing("messageGenerationTimestamp"))?,
}
if let Some(v) = &self.return_information {
w.key(1898)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.session_information {
w.key(2045)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.dynamic_information_extension {
w.key(708)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:ExchangeContext`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ExchangeContext {
/// XML element `ex:codedExchangeProtocol`.
pub coded_exchange_protocol: Option<ProtocolTypeEnum>,
/// XML element `ex:exchangeSpecificationVersion`.
pub exchange_specification_version: Option<String>,
/// XML element `ex:operatingMode`.
pub operating_mode: Option<OperatingModeEnum>,
/// XML element `ex:updateMethod`.
pub update_method: Option<UpdateMethodEnum>,
/// XML element `ex:nonCodedExchangeProtocol`.
pub non_coded_exchange_protocol: Option<String>,
/// XML element `ex:supplierOrCisRequester`.
pub supplier_or_cis_requester: Option<Box<Agent>>,
/// XML element `ex:clientOrCisProvider`.
pub client_or_cis_provider: Vec<Agent>,
/// XML element `ex:subscription`.
pub subscription: Option<Box<Subscription>>,
/// XML element `ex:_exchangeContextExtension`.
pub exchange_context_extension: Option<Box<Extension>>,
}
impl ExchangeContext {
const FIELDS: &'static [u32] = &[0x9074b, 0x9082b, 0x90a0e, 0x90c6a, 0x909a0, 0x90bf5, 0x90748, 0x90bea, 0x904b1];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x900ad);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = None;
let mut e4 = None;
let mut e5 = None;
let mut e6 = Vec::new();
let mut e7 = None;
let mut e8 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x9074b => { let v = r.enumeration::<ProtocolTypeEnum>()?; r.set(&mut e0, v, 1867); }
0x9082b => { let v = r.string()?; r.set(&mut e1, v, 2091); }
0x90a0e => { let v = r.enumeration::<OperatingModeEnum>()?; r.set(&mut e2, v, 2574); }
0x90c6a => { let v = r.enumeration::<UpdateMethodEnum>()?; r.set(&mut e3, v, 3178); }
0x909a0 => { let v = r.string()?; r.set(&mut e4, v, 2464); }
0x90bf5 => { let v = Some(Agent::read(r)?); r.set(&mut e5, v.map(Box::new), 3061); }
0x90748 => { let v = Some(Agent::read(r)?); e6.extend(v); }
0x90bea => { let v = Some(Subscription::read(r)?); r.set(&mut e7, v.map(Box::new), 3050); }
0x904b1 => { let v = r.raw()?; r.set(&mut e8, v.map(Box::new), 1201); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 1867);
r.required(&e1, 2091);
r.required(&e5, 3061);
let v = Self {
coded_exchange_protocol: e0,
exchange_specification_version: e1,
operating_mode: e2,
update_method: e3,
non_coded_exchange_protocol: e4,
supplier_or_cis_requester: e5,
client_or_cis_provider: e6,
subscription: e7,
exchange_context_extension: e8,
};
r.close();
Ok(v)
}
}
impl ExchangeContext {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
match &self.coded_exchange_protocol {
Some(v) => { w.enumeration("ex:codedExchangeProtocol", v.literal())?; }
None => return Err(w.missing("ex:codedExchangeProtocol")),
}
match &self.exchange_specification_version {
Some(v) => { w.max_len("exchangeSpecificationVersion", "String", v, 1024)?; w.leaf("ex:exchangeSpecificationVersion", v)?; }
None => return Err(w.missing("ex:exchangeSpecificationVersion")),
}
if let Some(v) = &self.operating_mode { w.enumeration("ex:operatingMode", v.literal())?; }
if let Some(v) = &self.update_method { w.enumeration("ex:updateMethod", v.literal())?; }
if let Some(v) = &self.non_coded_exchange_protocol { w.max_len("nonCodedExchangeProtocol", "String", v, 1024)?; w.leaf("ex:nonCodedExchangeProtocol", v)?; }
match &self.supplier_or_cis_requester {
Some(v) => { v.write(w, "ex:supplierOrCisRequester", "", "")?; }
None => return Err(w.missing("ex:supplierOrCisRequester")),
}
for v in &self.client_or_cis_provider { v.write(w, "ex:clientOrCisProvider", "", "")?; }
if let Some(v) = &self.subscription { v.write(w, "ex:subscription", "", "")?; }
if let Some(v) = &self.exchange_context_extension { w.extension("ex:_exchangeContextExtension", v)?; }
w.end(tag)
}
}
impl ExchangeContext {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 9];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
let mut f3 = None;
let mut f4 = None;
let mut f5 = None;
let mut f6 = Vec::new();
let mut f7 = None;
let mut f8 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
345 => if r.first(&mut seen[0])? { f0 = r.enumeration::<ProtocolTypeEnum>()?; },
717 => if r.first(&mut seen[1])? { f1 = r.string()?; },
1474 => if r.first(&mut seen[2])? { f2 = r.enumeration::<OperatingModeEnum>()?; },
2511 => if r.first(&mut seen[3])? { f3 = r.enumeration::<UpdateMethodEnum>()?; },
1364 => if r.first(&mut seen[4])? { f4 = r.string()?; },
2224 => if r.first(&mut seen[5])? { f5 = Agent::read_json(r)?.map(Box::new); },
342 => if r.first(&mut seen[6])? { let mut l = r.list()?; while r.item(&mut l)? { if let Some(v) = Agent::read_json(r)? { f6.push(v); } } },
2214 => if r.first(&mut seen[7])? { f7 = Subscription::read_json(r)?.map(Box::new); },
709 => if r.first(&mut seen[8])? { f8 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
r.required(&f0, 345);
r.required(&f1, 717);
r.required(&f5, 2224);
Ok(Self {
coded_exchange_protocol: f0,
exchange_specification_version: f1,
operating_mode: f2,
update_method: f3,
non_coded_exchange_protocol: f4,
supplier_or_cis_requester: f5,
client_or_cis_provider: f6,
subscription: f7,
exchange_context_extension: f8,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(344)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
match &self.coded_exchange_protocol {
Some(v) => {
w.key(345)?;
w.enumeration(351, v.literal())?;
}
None => w.absent(345, w.missing("codedExchangeProtocol"))?,
}
match &self.exchange_specification_version {
Some(v) => {
w.key(717)?;
w.max_len("exchangeSpecificationVersion", "String", v, 1024)?; w.string(v)?;
}
None => w.absent(717, w.missing("exchangeSpecificationVersion"))?,
}
if let Some(v) = &self.operating_mode {
w.key(1474)?;
w.enumeration(350, v.literal())?;
}
if let Some(v) = &self.update_method {
w.key(2511)?;
w.enumeration(355, v.literal())?;
}
if let Some(v) = &self.non_coded_exchange_protocol {
w.key(1364)?;
w.max_len("nonCodedExchangeProtocol", "String", v, 1024)?; w.string(v)?;
}
match &self.supplier_or_cis_requester {
Some(v) => {
w.key(2224)?;
v.write_json(w, None)?;
}
None => w.absent(2224, w.missing("supplierOrCisRequester"))?,
}
if !self.client_or_cis_provider.is_empty() {
w.key(342)?;
w.begin_array()?;
for v in &self.client_or_cis_provider {
w.item()?;
v.write_json(w, None)?;
}
w.end_array()?;
}
if let Some(v) = &self.subscription {
w.key(2214)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.exchange_context_extension {
w.key(709)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:ExchangeInformation`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ExchangeInformation {
/// XML attribute `extensionName`.
pub extension_name: Option<String>,
/// XML attribute `extensionVersion`.
pub extension_version: Option<String>,
/// XML attribute `profileName`.
pub profile_name: Option<String>,
/// XML attribute `profileVersion`.
pub profile_version: Option<String>,
/// XML element `ex:messageType`.
pub message_type: Option<MessageTypeEnum>,
/// XML element `ex:exchangeContext`.
pub exchange_context: Option<Box<ExchangeContext>>,
/// XML element `ex:dynamicInformation`.
pub dynamic_information: Option<Box<DynamicInformation>>,
/// XML element `ex:_exchangeInformationExtension`.
pub exchange_information_extension: Option<Box<Extension>>,
}
impl ExchangeInformation {
const FIELDS: &'static [u32] = &[0x9096e, 0x90829, 0x907df, 0x904b2];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x900ae);
let _ = r.attr(2439);
let a1 = r.attr(2104);
let a2 = r.attr(2105);
let a3 = r.attr(2760);
let a4 = r.attr(2761);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x9096e => { let v = r.enumeration::<MessageTypeEnum>()?; r.set(&mut e0, v, 2414); }
0x90829 => { let v = Some(ExchangeContext::read(r)?); r.set(&mut e1, v.map(Box::new), 2089); }
0x907df => { let v = Some(DynamicInformation::read(r)?); r.set(&mut e2, v.map(Box::new), 2015); }
0x904b2 => { let v = r.raw()?; r.set(&mut e3, v.map(Box::new), 1202); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e1, 2089);
r.required(&e2, 2015);
let v = Self {
extension_name: a1,
extension_version: a2,
profile_name: a3,
profile_version: a4,
message_type: e0,
exchange_context: e1,
dynamic_information: e2,
exchange_information_extension: e3,
};
r.close();
Ok(v)
}
}
impl ExchangeInformation {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
w.constant_attrs(" modelBaseVersion=\"3\"")?;
if let Some(v) = &self.extension_name { w.attr("extensionName", v)?; }
if let Some(v) = &self.extension_version { w.attr("extensionVersion", v)?; }
if let Some(v) = &self.profile_name { w.attr("profileName", v)?; }
if let Some(v) = &self.profile_version { w.attr("profileVersion", v)?; }
if let Some(v) = &self.message_type { w.enumeration("ex:messageType", v.literal())?; }
match &self.exchange_context {
Some(v) => { v.write(w, "ex:exchangeContext", "", "")?; }
None => return Err(w.missing("ex:exchangeContext")),
}
match &self.dynamic_information {
Some(v) => { v.write(w, "ex:dynamicInformation", "", "")?; }
None => return Err(w.missing("ex:dynamicInformation")),
}
if let Some(v) = &self.exchange_information_extension { w.extension("ex:_exchangeInformationExtension", v)?; }
w.end(tag)
}
}
impl ExchangeInformation {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 8];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
let mut f3 = None;
let mut f4 = None;
let mut f5 = None;
let mut f6 = None;
let mut f7 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
1316 => if r.first(&mut seen[4])? { f4 = r.enumeration::<MessageTypeEnum>()?; },
715 => if r.first(&mut seen[5])? { f5 = ExchangeContext::read_json(r)?.map(Box::new); },
600 => if r.first(&mut seen[6])? { f6 = DynamicInformation::read_json(r)?.map(Box::new); },
710 => if r.first(&mut seen[7])? { f7 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
r.required(&f5, 715);
r.required(&f6, 600);
Ok(Self {
extension_name: f0,
extension_version: f1,
profile_name: f2,
profile_version: f3,
message_type: f4,
exchange_context: f5,
dynamic_information: f6,
exchange_information_extension: f7,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(345)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
if self.extension_name.is_some() {
return Err(w.no_place("extensionName"));
}
if self.extension_version.is_some() {
return Err(w.no_place("extensionVersion"));
}
if self.profile_name.is_some() {
return Err(w.no_place("profileName"));
}
if self.profile_version.is_some() {
return Err(w.no_place("profileVersion"));
}
if let Some(v) = &self.message_type {
w.key(1316)?;
w.enumeration(349, v.literal())?;
}
match &self.exchange_context {
Some(v) => {
w.key(715)?;
v.write_json(w, None)?;
}
None => w.absent(715, w.missing("exchangeContext"))?,
}
match &self.dynamic_information {
Some(v) => {
w.key(600)?;
v.write_json(w, None)?;
}
None => w.absent(600, w.missing("dynamicInformation"))?,
}
if let Some(v) = &self.exchange_information_extension {
w.key(710)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:ReturnInformation`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ReturnInformation {
/// XML element `ex:returnStatus`.
pub return_status: Option<ExchangeReturnEnum>,
/// XML element `ex:returnStatusReason`.
pub return_status_reason: Option<MultilingualString>,
/// XML element `ex:codedInvalidityReason`.
pub coded_invalidity_reason: Vec<InvalidityReasonEnum>,
/// XML element `ex:_returnInformationExtension`.
pub return_information_extension: Option<Box<Extension>>,
}
impl ReturnInformation {
const FIELDS: &'static [u32] = &[0x90b3c, 0x90b3d, 0x9074c, 0x905c3];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x901c8);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = Vec::new();
let mut e3 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x90b3c => { let v = r.enumeration::<ExchangeReturnEnum>()?; r.set(&mut e0, v, 2876); }
0x90b3d => { let v = r.multilingual()?; r.set(&mut e1, v, 2877); }
0x9074c => { let v = r.enumeration::<InvalidityReasonEnum>()?; e2.extend(v); }
0x905c3 => { let v = r.raw()?; r.set(&mut e3, v.map(Box::new), 1475); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 2876);
let v = Self {
return_status: e0,
return_status_reason: e1,
coded_invalidity_reason: e2,
return_information_extension: e3,
};
r.close();
Ok(v)
}
}
impl ReturnInformation {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
match &self.return_status {
Some(v) => { w.enumeration("ex:returnStatus", v.literal())?; }
None => return Err(w.missing("ex:returnStatus")),
}
if let Some(v) = &self.return_status_reason { w.multilingual("ex:returnStatusReason", v)?; }
for v in &self.coded_invalidity_reason { w.enumeration("ex:codedInvalidityReason", v.literal())?; }
if let Some(v) = &self.return_information_extension { w.extension("ex:_returnInformationExtension", v)?; }
w.end(tag)
}
}
impl ReturnInformation {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 4];
let mut f0 = None;
let mut f1 = None;
let mut f2 = Vec::new();
let mut f3 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
1899 => if r.first(&mut seen[0])? { f0 = r.enumeration::<ExchangeReturnEnum>()?; },
1900 => if r.first(&mut seen[1])? { f1 = r.multilingual()?; },
346 => if r.first(&mut seen[2])? { let mut l = r.list()?; while r.item(&mut l)? { if let Some(v) = r.enumeration::<InvalidityReasonEnum>()? { f2.push(v); } } },
711 => if r.first(&mut seen[3])? { f3 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
r.required(&f0, 1899);
Ok(Self {
return_status: f0,
return_status_reason: f1,
coded_invalidity_reason: f2,
return_information_extension: f3,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(352)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
match &self.return_status {
Some(v) => {
w.key(1899)?;
w.enumeration(346, v.literal())?;
}
None => w.absent(1899, w.missing("returnStatus"))?,
}
if let Some(v) = &self.return_status_reason {
w.key(1900)?;
w.multilingual(v)?;
}
if !self.coded_invalidity_reason.is_empty() {
w.key(346)?;
w.begin_array()?;
for v in &self.coded_invalidity_reason {
w.item()?;
w.enumeration(348, v.literal())?;
}
w.end_array()?;
}
if let Some(v) = &self.return_information_extension {
w.key(711)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:SessionInformation`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct SessionInformation {
/// XML element `ex:sessionID`.
pub session_id: Option<String>,
/// XML element `ex:startSession`.
pub start_session: Option<DateTime>,
/// XML element `ex:_sessionInformationExtension`.
pub session_information_extension: Option<Box<Extension>>,
}
impl SessionInformation {
const FIELDS: &'static [u32] = &[0x90b8d, 0x90bca, 0x905df];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x901e4);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x90b8d => { let v = r.string()?; r.set(&mut e0, v, 2957); }
0x90bca => { let v = r.date_time()?; r.set(&mut e1, v, 3018); }
0x905df => { let v = r.raw()?; r.set(&mut e2, v.map(Box::new), 1503); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 2957);
let v = Self {
session_id: e0,
start_session: e1,
session_information_extension: e2,
};
r.close();
Ok(v)
}
}
impl SessionInformation {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
match &self.session_id {
Some(v) => { w.max_len("sessionID", "String", v, 1024)?; w.leaf("ex:sessionID", v)?; }
None => return Err(w.missing("ex:sessionID")),
}
if let Some(v) = &self.start_session { w.leaf("ex:startSession", v)?; }
if let Some(v) = &self.session_information_extension { w.extension("ex:_sessionInformationExtension", v)?; }
w.end(tag)
}
}
impl SessionInformation {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 3];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
2044 => if r.first(&mut seen[0])? { f0 = r.string()?; },
2183 => if r.first(&mut seen[1])? { f1 = r.date_time()?; },
712 => if r.first(&mut seen[2])? { f2 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
r.required(&f0, 2044);
Ok(Self {
session_id: f0,
start_session: f1,
session_information_extension: f2,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(353)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
match &self.session_id {
Some(v) => {
w.key(2044)?;
w.max_len("sessionID", "String", v, 1024)?; w.string(v)?;
}
None => w.absent(2044, w.missing("sessionID"))?,
}
if let Some(v) = &self.start_session {
w.key(2183)?;
w.date_time(v)?;
}
if let Some(v) = &self.session_information_extension {
w.key(712)?;
w.extension(v)?;
}
w.end_object()
}
}
/// XML type `ex:Subscription`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct Subscription {
/// XML element `ex:name`.
pub name: Option<String>,
/// XML element `ex:referenceID`.
pub reference_id: Option<Box<com::Reference>>,
/// XML element `ex:subscriptionStart`.
pub subscription_start: Option<DateTime>,
/// XML element `ex:subscriptionEnd`.
pub subscription_end: Option<DateTime>,
/// XML element `ex:deliveyFrequency`.
pub delivey_frequency: Option<com::NonNegativeInteger>,
/// XML element `ex:validity`.
pub validity: Option<Box<com::Validity>>,
/// XML element `ex:_subscriptionExtension`.
pub subscription_extension: Option<Box<Extension>>,
}
impl Subscription {
const FIELDS: &'static [u32] = &[0x9098b, 0x90b02, 0x90bec, 0x90beb, 0x9079e, 0x90c86, 0x90603];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0x9020a);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = None;
let mut e4 = None;
let mut e5 = None;
let mut e6 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0x9098b => { let v = r.string()?; r.set(&mut e0, v, 2443); }
0x90b02 => { let v = Some(com::Reference::read(r)?); r.set(&mut e1, v.map(Box::new), 2818); }
0x90bec => { let v = r.date_time()?; r.set(&mut e2, v, 3052); }
0x90beb => { let v = r.date_time()?; r.set(&mut e3, v, 3051); }
0x9079e => { let v = r.value::<u64>()?; r.set(&mut e4, v, 1950); }
0x90c86 => { let v = Some(com::Validity::read(r)?); r.set(&mut e5, v.map(Box::new), 3206); }
0x90603 => { let v = r.raw()?; r.set(&mut e6, v.map(Box::new), 1539); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
let v = Self {
name: e0,
reference_id: e1,
subscription_start: e2,
subscription_end: e3,
delivey_frequency: e4,
validity: e5,
subscription_extension: e6,
};
r.close();
Ok(v)
}
}
impl Subscription {
pub(crate) fn write(&self, w: &mut Out<'_>, tag: &'static str, kind: &'static str, fixed: &'static str) -> Result<(), Error> {
w.begin(tag)?;
w.constant_attrs(kind)?;
w.constant_attrs(fixed)?;
if let Some(v) = &self.name { w.max_len("name", "String", v, 1024)?; w.leaf("ex:name", v)?; }
if let Some(v) = &self.reference_id { v.write(w, "ex:referenceID", "", "")?; }
if let Some(v) = &self.subscription_start { w.leaf("ex:subscriptionStart", v)?; }
if let Some(v) = &self.subscription_end { w.leaf("ex:subscriptionEnd", v)?; }
if let Some(v) = &self.delivey_frequency { w.leaf("ex:deliveyFrequency", v)?; }
if let Some(v) = &self.validity { v.write(w, "ex:validity", "", "")?; }
if let Some(v) = &self.subscription_extension { w.extension("ex:_subscriptionExtension", v)?; }
w.end(tag)
}
}
impl Subscription {
pub(crate) fn read_json(r: &mut JsonReader<'_>) -> Result<Option<Self>, Error> {
if !r.begin_object()? {
return Ok(None);
}
Self::read_json_members(r, None).map(Some)
}
/// Reads the members of an object that is already open; `pending` is a member key read
/// already.
pub(crate) fn read_json_members(r: &mut JsonReader<'_>, mut pending: Option<u32>) -> Result<Self, Error> {
let mut seen = [false; 7];
let mut f0 = None;
let mut f1 = None;
let mut f2 = None;
let mut f3 = None;
let mut f4 = None;
let mut f5 = None;
let mut f6 = None;
loop {
let key = match pending.take() {
Some(key) => key,
None => match r.next_key()? {
Some(key) => key,
None => break,
},
};
match key {
1345 => if r.first(&mut seen[0])? { f0 = r.string()?; },
1818 => if r.first(&mut seen[1])? { f1 = com::Reference::read_json(r)?.map(Box::new); },
2216 => if r.first(&mut seen[2])? { f2 = r.date_time()?; },
2215 => if r.first(&mut seen[3])? { f3 = r.date_time()?; },
535 => if r.first(&mut seen[4])? { f4 = r.number::<u64>()?; },
2539 => if r.first(&mut seen[5])? { f5 = com::Validity::read_json(r)?.map(Box::new); },
713 => if r.first(&mut seen[6])? { f6 = r.raw_object()?.map(Box::new); },
_ => r.skip_unknown()?,
}
}
Ok(Self {
name: f0,
reference_id: f1,
subscription_start: f2,
subscription_end: f3,
delivey_frequency: f4,
validity: f5,
subscription_extension: f6,
})
}
pub(crate) fn write_json(&self, w: &mut JsonWriter<'_>, target_class: Option<&'static str>) -> Result<(), Error> {
w.begin_object(354)?;
if let Some(class) = target_class {
w.target_class(class)?;
}
if let Some(v) = &self.name {
w.key(1345)?;
w.max_len("name", "String", v, 1024)?; w.string(v)?;
}
if let Some(v) = &self.reference_id {
w.key(1818)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.subscription_start {
w.key(2216)?;
w.date_time(v)?;
}
if let Some(v) = &self.subscription_end {
w.key(2215)?;
w.date_time(v)?;
}
if let Some(v) = &self.delivey_frequency {
w.key(535)?;
w.integer(*v)?;
}
if let Some(v) = &self.validity {
w.key(2539)?;
v.write_json(w, None)?;
}
if let Some(v) = &self.subscription_extension {
w.key(713)?;
w.extension(v)?;
}
w.end_object()
}
}