#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
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};
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::app_gainforest::evaluator::MethodInfo;
use crate::app_gainforest::evaluator::service;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EvaluationTypeDefinition<S: BosStr = DefaultStr> {
pub identifier: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub locales: Option<Vec<service::EvaluationTypeLocale<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<MethodInfo<S>>,
pub result_type: 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 EvaluationTypeLocale<S: BosStr = DefaultStr> {
pub description: S,
pub lang: S,
pub 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)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EvaluatorPolicies<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub access_model: Option<EvaluatorPoliciesAccessModel<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub evaluation_type_definitions: Option<Vec<service::EvaluationTypeDefinition<S>>>,
pub evaluation_types: Vec<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject_collections: Option<Vec<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 EvaluatorPoliciesAccessModel<S: BosStr = DefaultStr> {
Open,
Subscription,
Other(S),
}
impl<S: BosStr> EvaluatorPoliciesAccessModel<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Open => "open",
Self::Subscription => "subscription",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"open" => Self::Open,
"subscription" => Self::Subscription,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for EvaluatorPoliciesAccessModel<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for EvaluatorPoliciesAccessModel<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for EvaluatorPoliciesAccessModel<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 EvaluatorPoliciesAccessModel<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 EvaluatorPoliciesAccessModel<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for EvaluatorPoliciesAccessModel<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = EvaluatorPoliciesAccessModel<S::Output>;
fn into_static(self) -> Self::Output {
match self {
EvaluatorPoliciesAccessModel::Open => EvaluatorPoliciesAccessModel::Open,
EvaluatorPoliciesAccessModel::Subscription => {
EvaluatorPoliciesAccessModel::Subscription
}
EvaluatorPoliciesAccessModel::Other(v) => {
EvaluatorPoliciesAccessModel::Other(v.into_static())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "app.gainforest.evaluator.service",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Service<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub policies: service::EvaluatorPolicies<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")]
pub struct ServiceGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Service<S>,
}
impl<S: BosStr> Service<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, ServiceRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for EvaluationTypeDefinition<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.service"
}
fn def_name() -> &'static str {
"evaluationTypeDefinition"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_service()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.identifier;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("identifier"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.locales {
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("locales"),
max: 20usize,
actual: value.len(),
});
}
}
{
let value = &self.result_type;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("result_type"),
max: 128usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EvaluationTypeLocale<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.service"
}
fn def_name() -> &'static str {
"evaluationTypeLocale"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_service()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.description;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 2048usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 2048usize,
actual: count,
});
}
}
}
{
let value = &self.lang;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 16usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("lang"),
max: 16usize,
actual: count,
});
}
}
}
{
let value = &self.name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 128usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("name"),
max: 128usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for EvaluatorPolicies<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.service"
}
fn def_name() -> &'static str {
"evaluatorPolicies"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_service()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.access_model {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("access_model"),
max: 64usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.evaluation_type_definitions {
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("evaluation_type_definitions"),
max: 20usize,
actual: value.len(),
});
}
}
{
let value = &self.evaluation_types;
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("evaluation_types"),
max: 20usize,
actual: value.len(),
});
}
}
if let Some(ref value) = self.subject_collections {
#[allow(unused_comparisons)]
if value.len() > 20usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("subject_collections"),
max: 20usize,
actual: value.len(),
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ServiceRecord;
impl XrpcResp for ServiceRecord {
const NSID: &'static str = "app.gainforest.evaluator.service";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ServiceGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<ServiceGetRecordOutput<S>> for Service<S> {
fn from(output: ServiceGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Service<S> {
const NSID: &'static str = "app.gainforest.evaluator.service";
type Record = ServiceRecord;
}
impl Collection for ServiceRecord {
const NSID: &'static str = "app.gainforest.evaluator.service";
type Record = ServiceRecord;
}
impl<S: BosStr> LexiconSchema for Service<S> {
fn nsid() -> &'static str {
"app.gainforest.evaluator.service"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_evaluator_service()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn lexicon_doc_app_gainforest_evaluator_service() -> 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("app.gainforest.evaluator.service"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("evaluationTypeDefinition"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Definition of a single evaluation type produced by this evaluator.",
),
),
required: Some(
vec![
SmolStr::new_static("identifier"),
SmolStr::new_static("resultType")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("identifier"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The evaluation type identifier (must match an entry in evaluationTypes).",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locales"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Human-readable names and descriptions in various languages.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#evaluationTypeLocale"),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("method"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"app.gainforest.evaluator.defs#methodInfo",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("resultType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The lexicon reference for the result type (e.g., 'app.gainforest.evaluator.defs#speciesIdResult').",
),
),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("evaluationTypeLocale"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Localized name and description for an evaluation type.",
),
),
required: Some(
vec![
SmolStr::new_static("lang"), SmolStr::new_static("name"),
SmolStr::new_static("description")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Longer description of what this evaluation type does.",
),
),
max_graphemes: Some(2048usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Language code (BCP-47, e.g., 'en', 'pt-BR').",
),
),
max_graphemes: Some(16usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Short human-readable name for this evaluation type.",
),
),
max_graphemes: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("evaluatorPolicies"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Policies declaring what this evaluator does and how it operates.",
),
),
required: Some(vec![SmolStr::new_static("evaluationTypes")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("accessModel"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Whether this evaluator requires user subscription ('subscription') or processes all matching records ('open').",
),
),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("evaluationTypeDefinitions"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Detailed definitions for each evaluation type, including human-readable descriptions.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#evaluationTypeDefinition"),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("evaluationTypes"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"List of evaluation type identifiers this evaluator produces (e.g., 'species-id', 'data-quality').",
),
),
items: LexArrayItem::String(LexString {
max_graphemes: Some(64usize),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subjectCollections"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"NSIDs of record collections this evaluator can evaluate (e.g., 'app.gainforest.dwc.occurrence').",
),
),
items: LexArrayItem::String(LexString {
max_graphemes: Some(128usize),
..Default::default()
}),
max_length: Some(20usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"An evaluator service declaration. Publish at /app.gainforest.evaluator.service/self to declare this account as an evaluator.",
),
),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("policies"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp of when this evaluator service was declared.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("policies"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#evaluatorPolicies"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod evaluator_policies_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 EvaluationTypes;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type EvaluationTypes = Unset;
}
pub struct SetEvaluationTypes<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEvaluationTypes<St> {}
impl<St: State> State for SetEvaluationTypes<St> {
type EvaluationTypes = Set<members::evaluation_types>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct evaluation_types(());
}
}
pub struct EvaluatorPoliciesBuilder<S: BosStr, St: evaluator_policies_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<EvaluatorPoliciesAccessModel<S>>,
Option<Vec<service::EvaluationTypeDefinition<S>>>,
Option<Vec<S>>,
Option<Vec<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> EvaluatorPolicies<S> {
pub fn new() -> EvaluatorPoliciesBuilder<S, evaluator_policies_state::Empty> {
EvaluatorPoliciesBuilder::new()
}
}
impl<S: BosStr> EvaluatorPoliciesBuilder<S, evaluator_policies_state::Empty> {
pub fn new() -> Self {
EvaluatorPoliciesBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: evaluator_policies_state::State> EvaluatorPoliciesBuilder<S, St> {
pub fn access_model(
mut self,
value: impl Into<Option<EvaluatorPoliciesAccessModel<S>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_access_model(
mut self,
value: Option<EvaluatorPoliciesAccessModel<S>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: evaluator_policies_state::State> EvaluatorPoliciesBuilder<S, St> {
pub fn evaluation_type_definitions(
mut self,
value: impl Into<Option<Vec<service::EvaluationTypeDefinition<S>>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_evaluation_type_definitions(
mut self,
value: Option<Vec<service::EvaluationTypeDefinition<S>>>,
) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> EvaluatorPoliciesBuilder<S, St>
where
St: evaluator_policies_state::State,
St::EvaluationTypes: evaluator_policies_state::IsUnset,
{
pub fn evaluation_types(
mut self,
value: impl Into<Vec<S>>,
) -> EvaluatorPoliciesBuilder<S, evaluator_policies_state::SetEvaluationTypes<St>> {
self._fields.2 = Option::Some(value.into());
EvaluatorPoliciesBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: evaluator_policies_state::State> EvaluatorPoliciesBuilder<S, St> {
pub fn subject_collections(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_subject_collections(mut self, value: Option<Vec<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> EvaluatorPoliciesBuilder<S, St>
where
St: evaluator_policies_state::State,
St::EvaluationTypes: evaluator_policies_state::IsSet,
{
pub fn build(self) -> EvaluatorPolicies<S> {
EvaluatorPolicies {
access_model: self._fields.0,
evaluation_type_definitions: self._fields.1,
evaluation_types: self._fields.2.unwrap(),
subject_collections: self._fields.3,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> EvaluatorPolicies<S> {
EvaluatorPolicies {
access_model: self._fields.0,
evaluation_type_definitions: self._fields.1,
evaluation_types: self._fields.2.unwrap(),
subject_collections: self._fields.3,
extra_data: Some(extra_data),
}
}
}
pub mod service_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 Policies;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Policies = Unset;
type CreatedAt = Unset;
}
pub struct SetPolicies<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPolicies<St> {}
impl<St: State> State for SetPolicies<St> {
type Policies = Set<members::policies>;
type CreatedAt = St::CreatedAt;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Policies = St::Policies;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct policies(());
pub struct created_at(());
}
}
pub struct ServiceBuilder<S: BosStr, St: service_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<service::EvaluatorPolicies<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Service<S> {
pub fn new() -> ServiceBuilder<S, service_state::Empty> {
ServiceBuilder::new()
}
}
impl<S: BosStr> ServiceBuilder<S, service_state::Empty> {
pub fn new() -> Self {
ServiceBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ServiceBuilder<S, St>
where
St: service_state::State,
St::CreatedAt: service_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ServiceBuilder<S, service_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
ServiceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ServiceBuilder<S, St>
where
St: service_state::State,
St::Policies: service_state::IsUnset,
{
pub fn policies(
mut self,
value: impl Into<service::EvaluatorPolicies<S>>,
) -> ServiceBuilder<S, service_state::SetPolicies<St>> {
self._fields.1 = Option::Some(value.into());
ServiceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ServiceBuilder<S, St>
where
St: service_state::State,
St::Policies: service_state::IsSet,
St::CreatedAt: service_state::IsSet,
{
pub fn build(self) -> Service<S> {
Service {
created_at: self._fields.0.unwrap(),
policies: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Service<S> {
Service {
created_at: self._fields.0.unwrap(),
policies: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}