pub mod evaluation;
pub mod service;
pub mod subscription;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_gainforest::evaluator;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CandidateTaxon<S: BosStr = DefaultStr> {
pub confidence: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub family: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gbif_taxon_key: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub genus: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub kingdom: Option<S>,
pub rank: i64,
pub scientific_name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ClassificationResult<S: BosStr = DefaultStr> {
pub category: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<S>,
pub value: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DataQualityResult<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub completeness_score: Option<i64>,
pub flags: Vec<evaluator::QualityFlag<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct DerivedMeasurement<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub measurement_method: Option<S>,
pub measurement_type: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub measurement_unit: Option<S>,
pub measurement_value: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct MeasurementResult<S: BosStr = DefaultStr> {
pub measurements: Vec<evaluator::DerivedMeasurement<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct MethodInfo<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub model_checkpoint: Option<S>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub references: Option<Vec<UriValue<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct QualityFlag<S: BosStr = DefaultStr> {
pub field: S,
pub issue: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub severity: Option<QualityFlagSeverity<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum QualityFlagSeverity<S: BosStr = DefaultStr> {
Error,
Warning,
Info,
Other(S),
}
impl<S: BosStr> QualityFlagSeverity<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Error => "error",
Self::Warning => "warning",
Self::Info => "info",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"error" => Self::Error,
"warning" => Self::Warning,
"info" => Self::Info,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for QualityFlagSeverity<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for QualityFlagSeverity<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for QualityFlagSeverity<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for QualityFlagSeverity<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for QualityFlagSeverity<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for QualityFlagSeverity<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = QualityFlagSeverity<S::Output>;
fn into_static(self) -> Self::Output {
match self {
QualityFlagSeverity::Error => QualityFlagSeverity::Error,
QualityFlagSeverity::Warning => QualityFlagSeverity::Warning,
QualityFlagSeverity::Info => QualityFlagSeverity::Info,
QualityFlagSeverity::Other(v) => QualityFlagSeverity::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SpeciesIdResult<S: BosStr = DefaultStr> {
pub candidates: Vec<evaluator::CandidateTaxon<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub input_feature: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SubjectRef<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct VerificationResult<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub remarks: Option<S>,
pub status: VerificationResultStatus<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub suggested_corrections: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_by: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_by_id: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VerificationResultStatus<S: BosStr = DefaultStr> {
Confirmed,
Rejected,
Uncertain,
Other(S),
}
impl<S: BosStr> VerificationResultStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Confirmed => "confirmed",
Self::Rejected => "rejected",
Self::Uncertain => "uncertain",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"confirmed" => Self::Confirmed,
"rejected" => Self::Rejected,
"uncertain" => Self::Uncertain,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for VerificationResultStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for VerificationResultStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for VerificationResultStatus<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for VerificationResultStatus<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for VerificationResultStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for VerificationResultStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = VerificationResultStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
VerificationResultStatus::Confirmed => VerificationResultStatus::Confirmed,
VerificationResultStatus::Rejected => VerificationResultStatus::Rejected,
VerificationResultStatus::Uncertain => VerificationResultStatus::Uncertain,
VerificationResultStatus::Other(v) => VerificationResultStatus::Other(v.into_static()),
}
}
}
impl<S: BosStr> LexiconSchema for CandidateTaxon<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"candidateTaxon"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.confidence;
if *value > 1000i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("confidence"),
max: 1000i64,
actual: *value,
});
}
}
{
let value = &self.confidence;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("confidence"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.family {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("family"),
max: 128usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.gbif_taxon_key {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("gbif_taxon_key"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.genus {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("genus"),
max: 128usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.kingdom {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("kingdom"),
max: 128usize,
actual: count,
});
}
}
}
{
let value = &self.rank;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("rank"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.scientific_name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 512usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("scientific_name"),
max: 512usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ClassificationResult<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"classificationResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.category;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("category"),
max: 128usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.remarks {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("remarks"),
max: 2048usize,
actual: count,
});
}
}
}
{
let value = &self.value;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("value"),
max: 256usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DataQualityResult<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"dataQualityResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.completeness_score {
if *value > 1000i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("completeness_score"),
max: 1000i64,
actual: *value,
});
}
}
if let Some(ref value) = self.completeness_score {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("completeness_score"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.flags;
#[allow(unused_comparisons)]
if value.len() > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("flags"),
max: 50usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.remarks {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("remarks"),
max: 2048usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for DerivedMeasurement<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"derivedMeasurement"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.measurement_method {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1024usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("measurement_method"),
max: 1024usize,
actual: count,
});
}
}
}
{
let value = &self.measurement_type;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("measurement_type"),
max: 256usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.measurement_unit {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("measurement_unit"),
max: 64usize,
actual: count,
});
}
}
}
{
let value = &self.measurement_value;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1024usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("measurement_value"),
max: 1024usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for MeasurementResult<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"measurementResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.measurements;
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("measurements"),
max: 20usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.remarks {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("remarks"),
max: 2048usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for MethodInfo<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"methodInfo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.model_checkpoint {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("model_checkpoint"),
max: 128usize,
actual: count,
});
}
}
}
{
let value = &self.name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("name"),
max: 256usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.references {
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("references"),
max: 10usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.version {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("version"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for QualityFlag<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"qualityFlag"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.field;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("field"),
max: 64usize,
actual: count,
});
}
}
}
{
let value = &self.issue;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("issue"),
max: 256usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.severity {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("severity"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SpeciesIdResult<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"speciesIdResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.candidates;
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("candidates"),
max: 20usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.input_feature {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("input_feature"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.remarks {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("remarks"),
max: 2048usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SubjectRef<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"subjectRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for VerificationResult<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.defs"
}
fn def_name() -> &'static str {
"verificationResult"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.remarks {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("remarks"),
max: 2048usize,
actual: count,
});
}
}
}
{
let value = &self.status;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("status"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.suggested_corrections {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 5000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("suggested_corrections"),
max: 5000usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.verified_by {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("verified_by"),
max: 256usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.verified_by_id {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("verified_by_id"),
max: 256usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod candidate_taxon_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ScientificName;
type Confidence;
type Rank;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ScientificName = Unset;
type Confidence = Unset;
type Rank = Unset;
}
pub struct SetScientificName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetScientificName<St> {}
impl<St: State> State for SetScientificName<St> {
type ScientificName = Set<members::scientific_name>;
type Confidence = St::Confidence;
type Rank = St::Rank;
}
pub struct SetConfidence<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetConfidence<St> {}
impl<St: State> State for SetConfidence<St> {
type ScientificName = St::ScientificName;
type Confidence = Set<members::confidence>;
type Rank = St::Rank;
}
pub struct SetRank<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRank<St> {}
impl<St: State> State for SetRank<St> {
type ScientificName = St::ScientificName;
type Confidence = St::Confidence;
type Rank = Set<members::rank>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct scientific_name(());
pub struct confidence(());
pub struct rank(());
}
}
pub struct CandidateTaxonBuilder<S: BosStr, St: candidate_taxon_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<i64>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<i64>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CandidateTaxon<S> {
pub fn new() -> CandidateTaxonBuilder<S, candidate_taxon_state::Empty> {
CandidateTaxonBuilder::new()
}
}
impl<S: BosStr> CandidateTaxonBuilder<S, candidate_taxon_state::Empty> {
pub fn new() -> Self {
CandidateTaxonBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CandidateTaxonBuilder<S, St>
where
St: candidate_taxon_state::State,
St::Confidence: candidate_taxon_state::IsUnset,
{
pub fn confidence(
mut self,
value: impl Into<i64>,
) -> CandidateTaxonBuilder<S, candidate_taxon_state::SetConfidence<St>> {
self._fields.0 = Option::Some(value.into());
CandidateTaxonBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: candidate_taxon_state::State> CandidateTaxonBuilder<S, St> {
pub fn family(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_family(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: candidate_taxon_state::State> CandidateTaxonBuilder<S, St> {
pub fn gbif_taxon_key(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_gbif_taxon_key(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: candidate_taxon_state::State> CandidateTaxonBuilder<S, St> {
pub fn genus(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_genus(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: candidate_taxon_state::State> CandidateTaxonBuilder<S, St> {
pub fn kingdom(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_kingdom(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> CandidateTaxonBuilder<S, St>
where
St: candidate_taxon_state::State,
St::Rank: candidate_taxon_state::IsUnset,
{
pub fn rank(
mut self,
value: impl Into<i64>,
) -> CandidateTaxonBuilder<S, candidate_taxon_state::SetRank<St>> {
self._fields.5 = Option::Some(value.into());
CandidateTaxonBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CandidateTaxonBuilder<S, St>
where
St: candidate_taxon_state::State,
St::ScientificName: candidate_taxon_state::IsUnset,
{
pub fn scientific_name(
mut self,
value: impl Into<S>,
) -> CandidateTaxonBuilder<S, candidate_taxon_state::SetScientificName<St>> {
self._fields.6 = Option::Some(value.into());
CandidateTaxonBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CandidateTaxonBuilder<S, St>
where
St: candidate_taxon_state::State,
St::ScientificName: candidate_taxon_state::IsSet,
St::Confidence: candidate_taxon_state::IsSet,
St::Rank: candidate_taxon_state::IsSet,
{
pub fn build(self) -> CandidateTaxon<S> {
CandidateTaxon {
confidence: self._fields.0.unwrap(),
family: self._fields.1,
gbif_taxon_key: self._fields.2,
genus: self._fields.3,
kingdom: self._fields.4,
rank: self._fields.5.unwrap(),
scientific_name: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CandidateTaxon<S> {
CandidateTaxon {
confidence: self._fields.0.unwrap(),
family: self._fields.1,
gbif_taxon_key: self._fields.2,
genus: self._fields.3,
kingdom: self._fields.4,
rank: self._fields.5.unwrap(),
scientific_name: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_gainforest_evaluator_defs() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("app.gainforest.evaluator.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("candidateTaxon"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A candidate taxon identification with confidence score and rank.",
)),
required: Some(vec![
SmolStr::new_static("scientificName"),
SmolStr::new_static("confidence"),
SmolStr::new_static("rank"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("confidence"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(1000i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("family"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Family of the candidate taxon.",
)),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gbifTaxonKey"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"GBIF backbone taxonomy key for the candidate.",
)),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("genus"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Genus of the candidate taxon.",
)),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("kingdom"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Kingdom of the candidate taxon.",
)),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rank"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scientificName"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Full scientific name of the candidate taxon.",
)),
max_graphemes: Some(512usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("classificationResult"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Generic categorical classification result (e.g., conservation priority, habitat type).",
),
),
required: Some(
vec![
SmolStr::new_static("category"), SmolStr::new_static("value")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("category"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The classification category (e.g., 'conservation-priority', 'habitat-type').",
),
),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("remarks"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Additional notes about the classification.",
),
),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The assigned classification value (e.g., 'critical', 'tropical-rainforest').",
),
),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("dataQualityResult"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Data quality assessment result with per-field quality flags.",
)),
required: Some(vec![SmolStr::new_static("flags")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("completenessScore"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
maximum: Some(1000i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("flags"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"List of quality issues found in the record.",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#qualityFlag"),
..Default::default()
}),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("remarks"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Additional notes about the quality assessment.",
)),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("derivedMeasurement"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A single measurement derived by an evaluator from source data.",
),
),
required: Some(
vec![
SmolStr::new_static("measurementType"),
SmolStr::new_static("measurementValue")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("measurementMethod"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Description of the method used to obtain the measurement.",
),
),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("measurementType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The nature of the measurement (e.g., 'canopy cover', 'NDVI', 'tree height').",
),
),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("measurementUnit"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The units for the measurement value (e.g., '%', 'm', 'kg').",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("measurementValue"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The value of the measurement."),
),
max_graphemes: Some(1024usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("measurementResult"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Derived measurements produced by an evaluator from source data (e.g., remote sensing metrics).",
),
),
required: Some(vec![SmolStr::new_static("measurements")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("measurements"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("List of derived measurements."),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#derivedMeasurement"),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("remarks"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Additional notes about the measurements.",
),
),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("methodInfo"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Provenance metadata describing the method used to produce an evaluation.",
),
),
required: Some(vec![SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("modelCheckpoint"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Identifier for the specific model checkpoint used (e.g., date or hash).",
),
),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Human-readable name of the method or model (e.g., 'GainForest BioClassifier').",
),
),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("references"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"URIs to papers, documentation, or repositories describing this method.",
),
),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("version"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Version string of the method or model (e.g., '2.1.0').",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("qualityFlag"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A single data quality flag indicating an issue with a specific field.",
)),
required: Some(vec![
SmolStr::new_static("field"),
SmolStr::new_static("issue"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("field"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The field name that has the quality issue.",
)),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("issue"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Description of the quality issue.",
)),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("severity"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Severity level of the quality issue.",
)),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("speciesIdResult"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"AI or human species recognition result with ranked candidate identifications.",
),
),
required: Some(vec![SmolStr::new_static("candidates")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("candidates"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Ranked list of candidate species identifications.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#candidateTaxon"),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("inputFeature"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Which feature of the subject record was used as input (e.g., 'mediaEvidence').",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("remarks"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Additional notes about the species identification.",
),
),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectRef"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Reference to a target record that is being evaluated.",
)),
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"CID pinning the exact version of the target record.",
)),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"AT-URI of the target record.",
)),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("verificationResult"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Expert verification result for a previous identification or evaluation.",
),
),
required: Some(vec![SmolStr::new_static("status")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("remarks"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Notes about the verification decision."),
),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Verification status: confirmed, rejected, or uncertain.",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("suggestedCorrections"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Suggested corrections if the original identification was rejected or uncertain.",
),
),
max_graphemes: Some(5000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("verifiedBy"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Name of the person who performed the verification.",
),
),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("verifiedByID"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Persistent identifier (e.g., ORCID) of the verifier.",
),
),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod data_quality_result_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Flags;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Flags = Unset;
}
pub struct SetFlags<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFlags<St> {}
impl<St: State> State for SetFlags<St> {
type Flags = Set<members::flags>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct flags(());
}
}
pub struct DataQualityResultBuilder<S: BosStr, St: data_quality_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<i64>,
Option<Vec<evaluator::QualityFlag<S>>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> DataQualityResult<S> {
pub fn new() -> DataQualityResultBuilder<S, data_quality_result_state::Empty> {
DataQualityResultBuilder::new()
}
}
impl<S: BosStr> DataQualityResultBuilder<S, data_quality_result_state::Empty> {
pub fn new() -> Self {
DataQualityResultBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: data_quality_result_state::State> DataQualityResultBuilder<S, St> {
pub fn completeness_score(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_completeness_score(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> DataQualityResultBuilder<S, St>
where
St: data_quality_result_state::State,
St::Flags: data_quality_result_state::IsUnset,
{
pub fn flags(
mut self,
value: impl Into<Vec<evaluator::QualityFlag<S>>>,
) -> DataQualityResultBuilder<S, data_quality_result_state::SetFlags<St>> {
self._fields.1 = Option::Some(value.into());
DataQualityResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: data_quality_result_state::State> DataQualityResultBuilder<S, St> {
pub fn remarks(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_remarks(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> DataQualityResultBuilder<S, St>
where
St: data_quality_result_state::State,
St::Flags: data_quality_result_state::IsSet,
{
pub fn build(self) -> DataQualityResult<S> {
DataQualityResult {
completeness_score: self._fields.0,
flags: self._fields.1.unwrap(),
remarks: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DataQualityResult<S> {
DataQualityResult {
completeness_score: self._fields.0,
flags: self._fields.1.unwrap(),
remarks: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod measurement_result_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Measurements;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Measurements = Unset;
}
pub struct SetMeasurements<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMeasurements<St> {}
impl<St: State> State for SetMeasurements<St> {
type Measurements = Set<members::measurements>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct measurements(());
}
}
pub struct MeasurementResultBuilder<S: BosStr, St: measurement_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<evaluator::DerivedMeasurement<S>>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> MeasurementResult<S> {
pub fn new() -> MeasurementResultBuilder<S, measurement_result_state::Empty> {
MeasurementResultBuilder::new()
}
}
impl<S: BosStr> MeasurementResultBuilder<S, measurement_result_state::Empty> {
pub fn new() -> Self {
MeasurementResultBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MeasurementResultBuilder<S, St>
where
St: measurement_result_state::State,
St::Measurements: measurement_result_state::IsUnset,
{
pub fn measurements(
mut self,
value: impl Into<Vec<evaluator::DerivedMeasurement<S>>>,
) -> MeasurementResultBuilder<S, measurement_result_state::SetMeasurements<St>> {
self._fields.0 = Option::Some(value.into());
MeasurementResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: measurement_result_state::State> MeasurementResultBuilder<S, St> {
pub fn remarks(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_remarks(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> MeasurementResultBuilder<S, St>
where
St: measurement_result_state::State,
St::Measurements: measurement_result_state::IsSet,
{
pub fn build(self) -> MeasurementResult<S> {
MeasurementResult {
measurements: self._fields.0.unwrap(),
remarks: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> MeasurementResult<S> {
MeasurementResult {
measurements: self._fields.0.unwrap(),
remarks: self._fields.1,
extra_data: Some(extra_data),
}
}
}
pub mod species_id_result_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Candidates;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Candidates = Unset;
}
pub struct SetCandidates<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCandidates<St> {}
impl<St: State> State for SetCandidates<St> {
type Candidates = Set<members::candidates>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct candidates(());
}
}
pub struct SpeciesIdResultBuilder<S: BosStr, St: species_id_result_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<evaluator::CandidateTaxon<S>>>,
Option<S>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SpeciesIdResult<S> {
pub fn new() -> SpeciesIdResultBuilder<S, species_id_result_state::Empty> {
SpeciesIdResultBuilder::new()
}
}
impl<S: BosStr> SpeciesIdResultBuilder<S, species_id_result_state::Empty> {
pub fn new() -> Self {
SpeciesIdResultBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SpeciesIdResultBuilder<S, St>
where
St: species_id_result_state::State,
St::Candidates: species_id_result_state::IsUnset,
{
pub fn candidates(
mut self,
value: impl Into<Vec<evaluator::CandidateTaxon<S>>>,
) -> SpeciesIdResultBuilder<S, species_id_result_state::SetCandidates<St>> {
self._fields.0 = Option::Some(value.into());
SpeciesIdResultBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: species_id_result_state::State> SpeciesIdResultBuilder<S, St> {
pub fn input_feature(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_input_feature(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: species_id_result_state::State> SpeciesIdResultBuilder<S, St> {
pub fn remarks(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_remarks(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> SpeciesIdResultBuilder<S, St>
where
St: species_id_result_state::State,
St::Candidates: species_id_result_state::IsSet,
{
pub fn build(self) -> SpeciesIdResult<S> {
SpeciesIdResult {
candidates: self._fields.0.unwrap(),
input_feature: self._fields.1,
remarks: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SpeciesIdResult<S> {
SpeciesIdResult {
candidates: self._fields.0.unwrap(),
input_feature: self._fields.1,
remarks: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod subject_ref_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct SubjectRefBuilder<S: BosStr, St: subject_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SubjectRef<S> {
pub fn new() -> SubjectRefBuilder<S, subject_ref_state::Empty> {
SubjectRefBuilder::new()
}
}
impl<S: BosStr> SubjectRefBuilder<S, subject_ref_state::Empty> {
pub fn new() -> Self {
SubjectRefBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: subject_ref_state::State> SubjectRefBuilder<S, St> {
pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> SubjectRefBuilder<S, St>
where
St: subject_ref_state::State,
St::Uri: subject_ref_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> SubjectRefBuilder<S, subject_ref_state::SetUri<St>> {
self._fields.1 = Option::Some(value.into());
SubjectRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubjectRefBuilder<S, St>
where
St: subject_ref_state::State,
St::Uri: subject_ref_state::IsSet,
{
pub fn build(self) -> SubjectRef<S> {
SubjectRef {
cid: self._fields.0,
uri: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SubjectRef<S> {
SubjectRef {
cid: self._fields.0,
uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}