#[allow(unused_imports)]
use super::{common as com, common_extension as comx, location_referencing as loc, 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};
#[allow(unused_imports)]
use crate::out::{Out, Pattern};
#[allow(unused_imports)]
use crate::xml::{Enumeration, Xml};
#[allow(unused_imports)]
use crate::{Date, DateTime, Decimal, Error, Extension, MultilingualString, Time};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AddressLineTypeEnum {
Apartment,
Building,
PoBox,
Unit,
Region,
Town,
DistrictTerritory,
Floor,
Street,
HouseNumber,
GeneralTextLine,
Extended(String),
}
impl AddressLineTypeEnum {
pub fn as_str(&self) -> &str {
match self {
Self::Apartment => "apartment",
Self::Building => "building",
Self::PoBox => "poBox",
Self::Unit => "unit",
Self::Region => "region",
Self::Town => "town",
Self::DistrictTerritory => "districtTerritory",
Self::Floor => "floor",
Self::Street => "street",
Self::HouseNumber => "houseNumber",
Self::GeneralTextLine => "generalTextLine",
Self::Extended(v) => v,
}
}
}
impl Enumeration for AddressLineTypeEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"apartment" => Some(Self::Apartment),
"building" => Some(Self::Building),
"poBox" => Some(Self::PoBox),
"unit" => Some(Self::Unit),
"region" => Some(Self::Region),
"town" => Some(Self::Town),
"districtTerritory" => Some(Self::DistrictTerritory),
"floor" => Some(Self::Floor),
"street" => Some(Self::Street),
"houseNumber" => Some(Self::HouseNumber),
"generalTextLine" => Some(Self::GeneralTextLine),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl AddressLineTypeEnum {
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum HouseNumberSideEnum {
Odd,
Even,
Extended(String),
}
impl HouseNumberSideEnum {
pub fn as_str(&self) -> &str {
match self {
Self::Odd => "odd",
Self::Even => "even",
Self::Extended(v) => v,
}
}
}
impl Enumeration for HouseNumberSideEnum {
fn from_literal(literal: &str) -> Option<Self> {
match literal {
"odd" => Some(Self::Odd),
"even" => Some(Self::Even),
_ => None,
}
}
fn extended(value: String) -> Self {
Self::Extended(value)
}
}
impl HouseNumberSideEnum {
#[allow(unreachable_patterns)]
pub(crate) fn literal(&self) -> (&str, Option<&str>) {
match self {
Self::Extended(v) => ("_extended", Some(v)),
other => (other.as_str(), None),
}
}
}
pub type NamedAreaCode = String;
#[derive(Debug, Clone, Default, PartialEq)]
pub struct Address {
pub postcode: Option<String>,
pub city: Option<MultilingualString>,
pub country_code: Option<com::CountryCode>,
pub address_line: Vec<AddressLine>,
pub address_extension: Option<Box<Extension>>,
}
impl Address {
const FIELDS: &'static [u32] = &[0xa0a57, 0xa0719, 0xa0748, 0xa0694, 0xa0404];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0xa0016);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
let mut e2 = None;
let mut e3 = Vec::new();
let mut e4 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0xa0a57 => { let v = r.string()?; r.set(&mut e0, v, 2647); }
0xa0719 => { let v = r.multilingual()?; r.set(&mut e1, v, 1817); }
0xa0748 => { let v = r.string()?; r.set(&mut e2, v, 1864); }
0xa0694 => { let v = Some(AddressLine::read(r)?); e3.extend(v); }
0xa0404 => { let v = r.raw()?; r.set(&mut e4, v.map(Box::new), 1028); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
let v = Self {
postcode: e0,
city: e1,
country_code: e2,
address_line: e3,
address_extension: e4,
};
r.close();
Ok(v)
}
}
impl Address {
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.postcode { w.max_len("postcode", v, 1024)?; w.leaf("locx:postcode", v)?; }
if let Some(v) = &self.city { w.multilingual("locx:city", v)?; }
if let Some(v) = &self.country_code { w.max_len("countryCode", v, 2)?; w.leaf("locx:countryCode", v)?; }
for v in &self.address_line { v.write(w, "locx:addressLine", "", "")?; }
if let Some(v) = &self.address_extension { w.extension("locx:_addressExtension", v)?; }
w.end(tag)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct AddressLine {
pub order: Option<com::NonNegativeInteger>,
pub r#type: Option<AddressLineTypeEnum>,
pub text: Option<MultilingualString>,
pub address_line_extension: Option<Box<Extension>>,
}
impl AddressLine {
const FIELDS: &'static [u32] = &[0xa0bfe, 0xa0bac, 0xa0405];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0xa0017);
let a0 = r.req_attr_value::<u64>(2521)?;
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 {
0xa0bfe => { let v = r.enumeration::<AddressLineTypeEnum>()?; r.set(&mut e0, v, 3070); }
0xa0bac => { let v = r.multilingual()?; r.set(&mut e1, v, 2988); }
0xa0405 => { let v = r.raw()?; r.set(&mut e2, v.map(Box::new), 1029); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 3070);
r.required(&e1, 2988);
let v = Self {
order: a0,
r#type: e0,
text: e1,
address_line_extension: e2,
};
r.close();
Ok(v)
}
}
impl AddressLine {
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.order {
Some(v) => { w.attr_value("order", v)?; }
None => return Err(w.missing_attr("order")),
}
match &self.r#type {
Some(v) => { w.enumeration("locx:type", v.literal())?; }
None => return Err(w.missing("locx:type")),
}
match &self.text {
Some(v) => { w.multilingual("locx:text", v)?; }
None => return Err(w.missing("locx:text")),
}
if let Some(v) = &self.address_line_extension { w.extension("locx:_addressLineExtension", v)?; }
w.end(tag)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct FacilityLocation {
pub time_zone: Option<fac::TimeZone>,
pub address: Option<Box<Address>>,
}
impl FacilityLocation {
const FIELDS: &'static [u32] = &[0xa0bbd, 0xa0693];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0xa00ac);
r.attrs_done();
let mut e0 = None;
let mut e1 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0xa0bbd => { let v = r.string()?; r.set(&mut e0, v, 3005); }
0xa0693 => { let v = Some(Address::read(r)?); r.set(&mut e1, v.map(Box::new), 1683); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
let v = Self {
time_zone: e0,
address: e1,
};
r.close();
Ok(v)
}
}
impl FacilityLocation {
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.time_zone { w.max_len("timeZone", v, 1024)?; w.pattern("timeZone", v, Pattern::TimeZone)?; w.leaf("locx:timeZone", v)?; }
if let Some(v) = &self.address { v.write(w, "locx:address", "", "")?; }
w.end(tag)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct NamedAreaExtended {
pub named_area_code: Option<NamedAreaCode>,
}
impl NamedAreaExtended {
const FIELDS: &'static [u32] = &[0xa094c];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0xa0114);
r.attrs_done();
let mut e0 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0xa094c => { let v = r.string()?; r.set(&mut e0, v, 2380); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
r.required(&e0, 2380);
let v = Self {
named_area_code: e0,
};
r.close();
Ok(v)
}
}
impl NamedAreaExtended {
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.named_area_code {
Some(v) => { w.max_len("namedAreaCode", v, 8)?; w.leaf("locx:namedAreaCode", v)?; }
None => return Err(w.missing("locx:namedAreaCode")),
}
w.end(tag)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct SupplementaryPositionalDescriptionExtended {
pub house_number_side: Option<HouseNumberSideEnum>,
}
impl SupplementaryPositionalDescriptionExtended {
const FIELDS: &'static [u32] = &[0xa0867];
pub(crate) fn read(r: &mut Xml<'_>) -> Result<Self, Error> {
r.expect_type(0xa0205);
r.attrs_done();
let mut e0 = None;
while let Some(mut key) = r.next_child()? {
loop {
match key {
0xa0867 => { let v = r.enumeration::<HouseNumberSideEnum>()?; r.set(&mut e0, v, 2151); }
_ => match r.fallback(key, Self::FIELDS) {
Some(k) => { key = k; continue; }
None => r.skip_unknown(key)?,
},
}
break;
}
}
let v = Self {
house_number_side: e0,
};
r.close();
Ok(v)
}
}
impl SupplementaryPositionalDescriptionExtended {
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.house_number_side { w.enumeration("locx:houseNumberSide", v.literal())?; }
w.end(tag)
}
}