#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::dev_sensorthings::datastream::UnitOfMeasurement;
use crate::dev_sensorthings::multi_observation;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MultiObservation<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub derived_from: Option<Vec<AtUri<'a>>>,
#[serde(borrow)]
pub entries: Vec<multi_observation::MultiObservationEntry<'a>>,
pub phenomenon_time: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub phenomenon_time_end: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub result_quality: Option<MultiObservationResultQuality<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub result_time: Option<Datetime>,
#[serde(borrow)]
pub sensor: AtUri<'a>,
#[serde(borrow)]
pub thing: AtUri<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MultiObservationResultQuality<'a> {
Good,
Suspect,
Missing,
Other(CowStr<'a>),
}
impl<'a> MultiObservationResultQuality<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Good => "dev.sensorthings.quality#good",
Self::Suspect => "dev.sensorthings.quality#suspect",
Self::Missing => "dev.sensorthings.quality#missing",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for MultiObservationResultQuality<'a> {
fn from(s: &'a str) -> Self {
match s {
"dev.sensorthings.quality#good" => Self::Good,
"dev.sensorthings.quality#suspect" => Self::Suspect,
"dev.sensorthings.quality#missing" => Self::Missing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for MultiObservationResultQuality<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"dev.sensorthings.quality#good" => Self::Good,
"dev.sensorthings.quality#suspect" => Self::Suspect,
"dev.sensorthings.quality#missing" => Self::Missing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for MultiObservationResultQuality<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for MultiObservationResultQuality<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for MultiObservationResultQuality<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for MultiObservationResultQuality<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for MultiObservationResultQuality<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for MultiObservationResultQuality<'_> {
type Output = MultiObservationResultQuality<'static>;
fn into_static(self) -> Self::Output {
match self {
MultiObservationResultQuality::Good => MultiObservationResultQuality::Good,
MultiObservationResultQuality::Suspect => {
MultiObservationResultQuality::Suspect
}
MultiObservationResultQuality::Missing => {
MultiObservationResultQuality::Missing
}
MultiObservationResultQuality::Other(v) => {
MultiObservationResultQuality::Other(v.into_static())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MultiObservationGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: MultiObservation<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MultiObservationEntry<'a> {
#[serde(borrow)]
pub observed_property: AtUri<'a>,
#[serde(borrow)]
pub result: MultiObservationEntryResult<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub result_quality: Option<MultiObservationEntryResultQuality<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub result_scale_factor: Option<i64>,
#[serde(borrow)]
pub unit_of_measurement: UnitOfMeasurement<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum MultiObservationEntryResult<'a> {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MultiObservationEntryResultQuality<'a> {
Good,
Suspect,
Missing,
Other(CowStr<'a>),
}
impl<'a> MultiObservationEntryResultQuality<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Good => "dev.sensorthings.quality#good",
Self::Suspect => "dev.sensorthings.quality#suspect",
Self::Missing => "dev.sensorthings.quality#missing",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for MultiObservationEntryResultQuality<'a> {
fn from(s: &'a str) -> Self {
match s {
"dev.sensorthings.quality#good" => Self::Good,
"dev.sensorthings.quality#suspect" => Self::Suspect,
"dev.sensorthings.quality#missing" => Self::Missing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for MultiObservationEntryResultQuality<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"dev.sensorthings.quality#good" => Self::Good,
"dev.sensorthings.quality#suspect" => Self::Suspect,
"dev.sensorthings.quality#missing" => Self::Missing,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for MultiObservationEntryResultQuality<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for MultiObservationEntryResultQuality<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for MultiObservationEntryResultQuality<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for MultiObservationEntryResultQuality<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for MultiObservationEntryResultQuality<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for MultiObservationEntryResultQuality<'_> {
type Output = MultiObservationEntryResultQuality<'static>;
fn into_static(self) -> Self::Output {
match self {
MultiObservationEntryResultQuality::Good => {
MultiObservationEntryResultQuality::Good
}
MultiObservationEntryResultQuality::Suspect => {
MultiObservationEntryResultQuality::Suspect
}
MultiObservationEntryResultQuality::Missing => {
MultiObservationEntryResultQuality::Missing
}
MultiObservationEntryResultQuality::Other(v) => {
MultiObservationEntryResultQuality::Other(v.into_static())
}
}
}
}
impl<'a> MultiObservation<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, MultiObservationRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct MultiObservationRecord;
impl XrpcResp for MultiObservationRecord {
const NSID: &'static str = "dev.sensorthings.multiObservation";
const ENCODING: &'static str = "application/json";
type Output<'de> = MultiObservationGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<MultiObservationGetRecordOutput<'_>> for MultiObservation<'_> {
fn from(output: MultiObservationGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for MultiObservation<'_> {
const NSID: &'static str = "dev.sensorthings.multiObservation";
type Record = MultiObservationRecord;
}
impl Collection for MultiObservationRecord {
const NSID: &'static str = "dev.sensorthings.multiObservation";
type Record = MultiObservationRecord;
}
impl<'a> LexiconSchema for MultiObservation<'a> {
fn nsid() -> &'static str {
"dev.sensorthings.multiObservation"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_sensorthings_multiObservation()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.derived_from {
#[allow(unused_comparisons)]
if value.len() > 16usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("derived_from"),
max: 16usize,
actual: value.len(),
});
}
}
{
let value = &self.entries;
#[allow(unused_comparisons)]
if value.len() > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("entries"),
max: 32usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.result_quality {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("result_quality"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for MultiObservationEntry<'a> {
fn nsid() -> &'static str {
"dev.sensorthings.multiObservation"
}
fn def_name() -> &'static str {
"multiObservationEntry"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_dev_sensorthings_multiObservation()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.result_quality {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("result_quality"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod multi_observation_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Entries;
type Thing;
type Sensor;
type PhenomenonTime;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Entries = Unset;
type Thing = Unset;
type Sensor = Unset;
type PhenomenonTime = Unset;
}
pub struct SetEntries<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEntries<S> {}
impl<S: State> State for SetEntries<S> {
type Entries = Set<members::entries>;
type Thing = S::Thing;
type Sensor = S::Sensor;
type PhenomenonTime = S::PhenomenonTime;
}
pub struct SetThing<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetThing<S> {}
impl<S: State> State for SetThing<S> {
type Entries = S::Entries;
type Thing = Set<members::thing>;
type Sensor = S::Sensor;
type PhenomenonTime = S::PhenomenonTime;
}
pub struct SetSensor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSensor<S> {}
impl<S: State> State for SetSensor<S> {
type Entries = S::Entries;
type Thing = S::Thing;
type Sensor = Set<members::sensor>;
type PhenomenonTime = S::PhenomenonTime;
}
pub struct SetPhenomenonTime<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPhenomenonTime<S> {}
impl<S: State> State for SetPhenomenonTime<S> {
type Entries = S::Entries;
type Thing = S::Thing;
type Sensor = S::Sensor;
type PhenomenonTime = Set<members::phenomenon_time>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct entries(());
pub struct thing(());
pub struct sensor(());
pub struct phenomenon_time(());
}
}
pub struct MultiObservationBuilder<'a, S: multi_observation_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<AtUri<'a>>>,
Option<Vec<multi_observation::MultiObservationEntry<'a>>>,
Option<Datetime>,
Option<Datetime>,
Option<MultiObservationResultQuality<'a>>,
Option<Datetime>,
Option<AtUri<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> MultiObservation<'a> {
pub fn new() -> MultiObservationBuilder<'a, multi_observation_state::Empty> {
MultiObservationBuilder::new()
}
}
impl<'a> MultiObservationBuilder<'a, multi_observation_state::Empty> {
pub fn new() -> Self {
MultiObservationBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: multi_observation_state::State> MultiObservationBuilder<'a, S> {
pub fn derived_from(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_derived_from(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> MultiObservationBuilder<'a, S>
where
S: multi_observation_state::State,
S::Entries: multi_observation_state::IsUnset,
{
pub fn entries(
mut self,
value: impl Into<Vec<multi_observation::MultiObservationEntry<'a>>>,
) -> MultiObservationBuilder<'a, multi_observation_state::SetEntries<S>> {
self._fields.1 = Option::Some(value.into());
MultiObservationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationBuilder<'a, S>
where
S: multi_observation_state::State,
S::PhenomenonTime: multi_observation_state::IsUnset,
{
pub fn phenomenon_time(
mut self,
value: impl Into<Datetime>,
) -> MultiObservationBuilder<'a, multi_observation_state::SetPhenomenonTime<S>> {
self._fields.2 = Option::Some(value.into());
MultiObservationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: multi_observation_state::State> MultiObservationBuilder<'a, S> {
pub fn phenomenon_time_end(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_phenomenon_time_end(mut self, value: Option<Datetime>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: multi_observation_state::State> MultiObservationBuilder<'a, S> {
pub fn result_quality(
mut self,
value: impl Into<Option<MultiObservationResultQuality<'a>>>,
) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_result_quality(
mut self,
value: Option<MultiObservationResultQuality<'a>>,
) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S: multi_observation_state::State> MultiObservationBuilder<'a, S> {
pub fn result_time(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_result_time(mut self, value: Option<Datetime>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> MultiObservationBuilder<'a, S>
where
S: multi_observation_state::State,
S::Sensor: multi_observation_state::IsUnset,
{
pub fn sensor(
mut self,
value: impl Into<AtUri<'a>>,
) -> MultiObservationBuilder<'a, multi_observation_state::SetSensor<S>> {
self._fields.6 = Option::Some(value.into());
MultiObservationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationBuilder<'a, S>
where
S: multi_observation_state::State,
S::Thing: multi_observation_state::IsUnset,
{
pub fn thing(
mut self,
value: impl Into<AtUri<'a>>,
) -> MultiObservationBuilder<'a, multi_observation_state::SetThing<S>> {
self._fields.7 = Option::Some(value.into());
MultiObservationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationBuilder<'a, S>
where
S: multi_observation_state::State,
S::Entries: multi_observation_state::IsSet,
S::Thing: multi_observation_state::IsSet,
S::Sensor: multi_observation_state::IsSet,
S::PhenomenonTime: multi_observation_state::IsSet,
{
pub fn build(self) -> MultiObservation<'a> {
MultiObservation {
derived_from: self._fields.0,
entries: self._fields.1.unwrap(),
phenomenon_time: self._fields.2.unwrap(),
phenomenon_time_end: self._fields.3,
result_quality: self._fields.4,
result_time: self._fields.5,
sensor: self._fields.6.unwrap(),
thing: self._fields.7.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> MultiObservation<'a> {
MultiObservation {
derived_from: self._fields.0,
entries: self._fields.1.unwrap(),
phenomenon_time: self._fields.2.unwrap(),
phenomenon_time_end: self._fields.3,
result_quality: self._fields.4,
result_time: self._fields.5,
sensor: self._fields.6.unwrap(),
thing: self._fields.7.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_dev_sensorthings_multiObservation() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("dev.sensorthings.multiObservation"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A composite observation bundling multiple co-produced results from a single act of sensing. Each entry carries its own ObservedProperty, unit, and scale metadata. Use this instead of separate Observations when the results are genuinely co-produced (e.g. wave statistics from spectral processing) and have no independent existence.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("thing"), SmolStr::new_static("sensor"),
SmolStr::new_static("phenomenonTime"),
SmolStr::new_static("entries")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("derivedFrom"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"AT-URIs of source observations or datastreams",
),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
max_length: Some(16usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("entries"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Array of co-produced result entries"),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#multiObservationEntry"),
..Default::default()
}),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("phenomenonTime"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Time the phenomenon was observed. Start of interval if phenomenonTimeEnd is present.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("phenomenonTimeEnd"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"End of observation interval. For wave statistics, this is the end of the burst window.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultQuality"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Quality flag applying to the composite observation as a whole",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultTime"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Time the results became available"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sensor"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the dev.sensorthings.sensor record (the instrument or process that co-produced these results)",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("thing"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the dev.sensorthings.thing record",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("multiObservationEntry"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A single result within a composite observation, fully self-describing.",
),
),
required: Some(
vec![
SmolStr::new_static("observedProperty"),
SmolStr::new_static("unitOfMeasurement"),
SmolStr::new_static("result")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("observedProperty"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the dev.sensorthings.observedProperty record",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("result"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("dev.sensorthings.observation#numericResult"),
CowStr::new_static("dev.sensorthings.observation#categoryResult"),
CowStr::new_static("dev.sensorthings.observation#booleanResult"),
CowStr::new_static("dev.sensorthings.observation#arrayResult"),
CowStr::new_static("dev.sensorthings.observation#geoPointResult")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultQuality"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Quality flag for this specific entry, if different from the composite quality",
),
),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultScaleFactor"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("unitOfMeasurement"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"dev.sensorthings.datastream#unitOfMeasurement",
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod multi_observation_entry_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ObservedProperty;
type Result;
type UnitOfMeasurement;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ObservedProperty = Unset;
type Result = Unset;
type UnitOfMeasurement = Unset;
}
pub struct SetObservedProperty<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetObservedProperty<S> {}
impl<S: State> State for SetObservedProperty<S> {
type ObservedProperty = Set<members::observed_property>;
type Result = S::Result;
type UnitOfMeasurement = S::UnitOfMeasurement;
}
pub struct SetResult<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetResult<S> {}
impl<S: State> State for SetResult<S> {
type ObservedProperty = S::ObservedProperty;
type Result = Set<members::result>;
type UnitOfMeasurement = S::UnitOfMeasurement;
}
pub struct SetUnitOfMeasurement<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUnitOfMeasurement<S> {}
impl<S: State> State for SetUnitOfMeasurement<S> {
type ObservedProperty = S::ObservedProperty;
type Result = S::Result;
type UnitOfMeasurement = Set<members::unit_of_measurement>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct observed_property(());
pub struct result(());
pub struct unit_of_measurement(());
}
}
pub struct MultiObservationEntryBuilder<'a, S: multi_observation_entry_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<AtUri<'a>>,
Option<MultiObservationEntryResult<'a>>,
Option<MultiObservationEntryResultQuality<'a>>,
Option<i64>,
Option<UnitOfMeasurement<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> MultiObservationEntry<'a> {
pub fn new() -> MultiObservationEntryBuilder<
'a,
multi_observation_entry_state::Empty,
> {
MultiObservationEntryBuilder::new()
}
}
impl<'a> MultiObservationEntryBuilder<'a, multi_observation_entry_state::Empty> {
pub fn new() -> Self {
MultiObservationEntryBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationEntryBuilder<'a, S>
where
S: multi_observation_entry_state::State,
S::ObservedProperty: multi_observation_entry_state::IsUnset,
{
pub fn observed_property(
mut self,
value: impl Into<AtUri<'a>>,
) -> MultiObservationEntryBuilder<
'a,
multi_observation_entry_state::SetObservedProperty<S>,
> {
self._fields.0 = Option::Some(value.into());
MultiObservationEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationEntryBuilder<'a, S>
where
S: multi_observation_entry_state::State,
S::Result: multi_observation_entry_state::IsUnset,
{
pub fn result(
mut self,
value: impl Into<MultiObservationEntryResult<'a>>,
) -> MultiObservationEntryBuilder<'a, multi_observation_entry_state::SetResult<S>> {
self._fields.1 = Option::Some(value.into());
MultiObservationEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: multi_observation_entry_state::State> MultiObservationEntryBuilder<'a, S> {
pub fn result_quality(
mut self,
value: impl Into<Option<MultiObservationEntryResultQuality<'a>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_result_quality(
mut self,
value: Option<MultiObservationEntryResultQuality<'a>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: multi_observation_entry_state::State> MultiObservationEntryBuilder<'a, S> {
pub fn result_scale_factor(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_result_scale_factor(mut self, value: Option<i64>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> MultiObservationEntryBuilder<'a, S>
where
S: multi_observation_entry_state::State,
S::UnitOfMeasurement: multi_observation_entry_state::IsUnset,
{
pub fn unit_of_measurement(
mut self,
value: impl Into<UnitOfMeasurement<'a>>,
) -> MultiObservationEntryBuilder<
'a,
multi_observation_entry_state::SetUnitOfMeasurement<S>,
> {
self._fields.4 = Option::Some(value.into());
MultiObservationEntryBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MultiObservationEntryBuilder<'a, S>
where
S: multi_observation_entry_state::State,
S::ObservedProperty: multi_observation_entry_state::IsSet,
S::Result: multi_observation_entry_state::IsSet,
S::UnitOfMeasurement: multi_observation_entry_state::IsSet,
{
pub fn build(self) -> MultiObservationEntry<'a> {
MultiObservationEntry {
observed_property: self._fields.0.unwrap(),
result: self._fields.1.unwrap(),
result_quality: self._fields.2,
result_scale_factor: self._fields.3,
unit_of_measurement: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> MultiObservationEntry<'a> {
MultiObservationEntry {
observed_property: self._fields.0.unwrap(),
result: self._fields.1.unwrap(),
result_quality: self._fields.2,
result_scale_factor: self._fields.3,
unit_of_measurement: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}