#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Service<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub broadcast: std::option::Option<Vec<crate::media_ionosphere::Broadcast<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub description: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub genres: std::option::Option<Vec<crate::media_ionosphere::Genre<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub geolocation: std::option::Option<crate::media_ionosphere::Geocoordinates<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub icon: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
#[serde(borrow)]
pub ionosphere: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub keywords: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
pub language: jacquard_common::types::string::Language,
#[serde(borrow)]
pub name: jacquard_common::CowStr<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub presentation_language: std::option::Option<
jacquard_common::types::string::Language,
>,
}
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 Language;
type Name;
type Ionosphere;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Language = Unset;
type Name = Unset;
type Ionosphere = Unset;
}
pub struct SetLanguage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLanguage<S> {}
impl<S: State> State for SetLanguage<S> {
type Language = Set<members::language>;
type Name = S::Name;
type Ionosphere = S::Ionosphere;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Language = S::Language;
type Name = Set<members::name>;
type Ionosphere = S::Ionosphere;
}
pub struct SetIonosphere<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIonosphere<S> {}
impl<S: State> State for SetIonosphere<S> {
type Language = S::Language;
type Name = S::Name;
type Ionosphere = Set<members::ionosphere>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct language(());
pub struct name(());
pub struct ionosphere(());
}
}
pub struct ServiceBuilder<'a, S: service_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::media_ionosphere::Broadcast<'a>>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<crate::media_ionosphere::Genre<'a>>>,
::core::option::Option<crate::media_ionosphere::Geocoordinates<'a>>,
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
::core::option::Option<jacquard_common::types::string::Language>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::Language>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Service<'a> {
pub fn new() -> ServiceBuilder<'a, service_state::Empty> {
ServiceBuilder::new()
}
}
impl<'a> ServiceBuilder<'a, service_state::Empty> {
pub fn new() -> Self {
ServiceBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn broadcast(
mut self,
value: impl Into<Option<Vec<crate::media_ionosphere::Broadcast<'a>>>>,
) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_broadcast(
mut self,
value: Option<Vec<crate::media_ionosphere::Broadcast<'a>>>,
) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn description(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_description(
mut self,
value: Option<jacquard_common::CowStr<'a>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn genres(
mut self,
value: impl Into<Option<Vec<crate::media_ionosphere::Genre<'a>>>>,
) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_genres(
mut self,
value: Option<Vec<crate::media_ionosphere::Genre<'a>>>,
) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn geolocation(
mut self,
value: impl Into<Option<crate::media_ionosphere::Geocoordinates<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_geolocation(
mut self,
value: Option<crate::media_ionosphere::Geocoordinates<'a>>,
) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn icon(
mut self,
value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_icon(
mut self,
value: Option<jacquard_common::types::blob::BlobRef<'a>>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S> ServiceBuilder<'a, S>
where
S: service_state::State,
S::Ionosphere: service_state::IsUnset,
{
pub fn ionosphere(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ServiceBuilder<'a, service_state::SetIonosphere<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
ServiceBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn keywords(
mut self,
value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
) -> Self {
self.__unsafe_private_named.6 = value.into();
self
}
pub fn maybe_keywords(
mut self,
value: Option<Vec<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.6 = value;
self
}
}
impl<'a, S> ServiceBuilder<'a, S>
where
S: service_state::State,
S::Language: service_state::IsUnset,
{
pub fn language(
mut self,
value: impl Into<jacquard_common::types::string::Language>,
) -> ServiceBuilder<'a, service_state::SetLanguage<S>> {
self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
ServiceBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> ServiceBuilder<'a, S>
where
S: service_state::State,
S::Name: service_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> ServiceBuilder<'a, service_state::SetName<S>> {
self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
ServiceBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: service_state::State> ServiceBuilder<'a, S> {
pub fn presentation_language(
mut self,
value: impl Into<Option<jacquard_common::types::string::Language>>,
) -> Self {
self.__unsafe_private_named.9 = value.into();
self
}
pub fn maybe_presentation_language(
mut self,
value: Option<jacquard_common::types::string::Language>,
) -> Self {
self.__unsafe_private_named.9 = value;
self
}
}
impl<'a, S> ServiceBuilder<'a, S>
where
S: service_state::State,
S::Language: service_state::IsSet,
S::Name: service_state::IsSet,
S::Ionosphere: service_state::IsSet,
{
pub fn build(self) -> Service<'a> {
Service {
broadcast: self.__unsafe_private_named.0,
description: self.__unsafe_private_named.1,
genres: self.__unsafe_private_named.2,
geolocation: self.__unsafe_private_named.3,
icon: self.__unsafe_private_named.4,
ionosphere: self.__unsafe_private_named.5.unwrap(),
keywords: self.__unsafe_private_named.6,
language: self.__unsafe_private_named.7.unwrap(),
name: self.__unsafe_private_named.8.unwrap(),
presentation_language: self.__unsafe_private_named.9,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Service<'a> {
Service {
broadcast: self.__unsafe_private_named.0,
description: self.__unsafe_private_named.1,
genres: self.__unsafe_private_named.2,
geolocation: self.__unsafe_private_named.3,
icon: self.__unsafe_private_named.4,
ionosphere: self.__unsafe_private_named.5.unwrap(),
keywords: self.__unsafe_private_named.6,
language: self.__unsafe_private_named.7.unwrap(),
name: self.__unsafe_private_named.8.unwrap(),
presentation_language: self.__unsafe_private_named.9,
extra_data: Some(extra_data),
}
}
}
impl<'a> Service<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, ServiceRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct ServiceGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Service<'a>,
}
impl From<ServiceGetRecordOutput<'_>> for Service<'_> {
fn from(output: ServiceGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Service<'_> {
const NSID: &'static str = "media.ionosphere.service";
type Record = ServiceRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct ServiceRecord;
impl jacquard_common::xrpc::XrpcResp for ServiceRecord {
const NSID: &'static str = "media.ionosphere.service";
const ENCODING: &'static str = "application/json";
type Output<'de> = ServiceGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for ServiceRecord {
const NSID: &'static str = "media.ionosphere.service";
type Record = ServiceRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Service<'a> {
fn nsid() -> &'static str {
"media.ionosphere.service"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_media_ionosphere_service()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"description",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.icon {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/*"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"icon",
),
accepted: vec!["image/*".to_string()],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.ionosphere;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"ionosphere",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
{
let count = jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation::graphemes(
value.as_ref(),
true,
)
.count();
if count > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 128usize,
actual: count,
});
}
}
}
Ok(())
}
}
fn lexicon_doc_media_ionosphere_service() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("media.ionosphere.service"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Represents the service belonging to this PDS",
),
),
key: Some(::jacquard_common::CowStr::new_static("literal:self")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("ionosphere"),
::jacquard_common::deps::smol_str::SmolStr::new_static("name"),
::jacquard_common::deps::smol_str::SmolStr::new_static("language")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"broadcast",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"media.ionosphere.defs#broadcast",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"description",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"genres",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
description: None,
r#ref: ::jacquard_common::CowStr::new_static(
"media.ionosphere.defs#genre",
),
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"geolocation",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
description: None,
refs: vec![
::jacquard_common::CowStr::new_static("media.ionosphere.defs#geocoordinates")
],
closed: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"icon",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
description: None,
accept: None,
max_size: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"ionosphere",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static("Version identifier"),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"keywords",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
description: None,
items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
min_length: None,
max_length: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"language",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"The language of the string values in this record. NOT the language of the content",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Language,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"name",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: None,
format: None,
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: Some(128usize),
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"presentationLanguage",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"This is the language that the content is actually presented in. If multiple, choose to omit this.",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Language,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}