#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, Did, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{lexicon, IntoStatic};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::fm_atradio::comment;
use crate::fm_atradio::StationInfo;
#[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 Gif<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub preview_url: Option<UriValue<S>>,
pub url: UriValue<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
#[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",
rename = "fm.atradio.comment",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Comment<S: BosStr = DefaultStr> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<comment::Mention<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gif: Option<comment::Gif<S>>,
pub station: StationInfo<S>,
pub text: 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 CommentGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Comment<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Mention<S: BosStr = DefaultStr> {
pub byte_end: i64,
pub byte_start: i64,
pub did: Did<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Comment<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, CommentRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for Gif<S> {
fn nsid() -> &'static str {
"fm.atradio.comment"
}
fn def_name() -> &'static str {
"gif"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_fm_atradio_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alt {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("alt"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.height {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("height"),
min: 0i64,
actual: *value,
});
}
}
if let Some(ref value) = self.width {
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("width"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CommentRecord;
impl XrpcResp for CommentRecord {
const NSID: &'static str = "fm.atradio.comment";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CommentGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<CommentGetRecordOutput<S>> for Comment<S> {
fn from(output: CommentGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Comment<S> {
const NSID: &'static str = "fm.atradio.comment";
type Record = CommentRecord;
}
impl Collection for CommentRecord {
const NSID: &'static str = "fm.atradio.comment";
type Record = CommentRecord;
}
impl<S: BosStr> LexiconSchema for Comment<S> {
fn nsid() -> &'static str {
"fm.atradio.comment"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_fm_atradio_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 300usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 300usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Mention<S> {
fn nsid() -> &'static str {
"fm.atradio.comment"
}
fn def_name() -> &'static str {
"mention"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_fm_atradio_comment()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.byte_end;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_end"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.byte_start;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_start"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
pub mod gif_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 Url;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Url = Unset;
}
pub struct SetUrl<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUrl<St> {}
impl<St: State> State for SetUrl<St> {
type Url = Set<members::url>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct url(());
}
}
pub struct GifBuilder<St: gif_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<i64>,
Option<UriValue<S>>,
Option<UriValue<S>>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl Gif<DefaultStr> {
pub fn new() -> GifBuilder<gif_state::Empty, DefaultStr> {
GifBuilder::new()
}
}
impl<S: BosStr> Gif<S> {
pub fn builder() -> GifBuilder<gif_state::Empty, S> {
GifBuilder::builder()
}
}
impl GifBuilder<gif_state::Empty, DefaultStr> {
pub fn new() -> Self {
GifBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> GifBuilder<gif_state::Empty, S> {
pub fn builder() -> Self {
GifBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St: gif_state::State, S: BosStr> GifBuilder<St, S> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<St: gif_state::State, S: BosStr> GifBuilder<St, S> {
pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_height(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<St: gif_state::State, S: BosStr> GifBuilder<St, S> {
pub fn preview_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_preview_url(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<St, S: BosStr> GifBuilder<St, S>
where
St: gif_state::State,
St::Url: gif_state::IsUnset,
{
pub fn url(mut self, value: impl Into<UriValue<S>>) -> GifBuilder<gif_state::SetUrl<St>, S> {
self._fields.3 = Option::Some(value.into());
GifBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: gif_state::State, S: BosStr> GifBuilder<St, S> {
pub fn width(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_width(mut self, value: Option<i64>) -> Self {
self._fields.4 = value;
self
}
}
impl<St, S: BosStr> GifBuilder<St, S>
where
St: gif_state::State,
St::Url: gif_state::IsSet,
{
pub fn build(self) -> Gif<S> {
Gif {
alt: self._fields.0,
height: self._fields.1,
preview_url: self._fields.2,
url: self._fields.3.unwrap(),
width: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Gif<S> {
Gif {
alt: self._fields.0,
height: self._fields.1,
preview_url: self._fields.2,
url: self._fields.3.unwrap(),
width: self._fields.4,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_fm_atradio_comment() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{deps::smol_str::SmolStr, types::blob::MimeType, CowStr};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("fm.atradio.comment"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("gif"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"An animated GIF embedded in a comment (e.g. from Giphy).",
)),
required: Some(vec![SmolStr::new_static("url")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
max_length: Some(512usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("previewUrl"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Smaller still/preview image URL.",
)),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Direct URL of the animated GIF/MP4.",
)),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("A user's comment on a radio station."),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("station"), SmolStr::new_static("text"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Mentions of other actors, anchored to byte ranges in `text`.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("fm.atradio.comment#mention"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gif"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("fm.atradio.comment#gif"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("station"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("fm.atradio.defs#stationInfo"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The comment body (plain text)."),
),
max_length: Some(3000usize),
max_graphemes: Some(300usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mention"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A mention of another actor within the comment text.",
)),
required: Some(vec![
SmolStr::new_static("did"),
SmolStr::new_static("byteStart"),
SmolStr::new_static("byteEnd"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("byteEnd"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("byteStart"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod comment_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 CreatedAt;
type Station;
type Text;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Station = Unset;
type Text = Unset;
}
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 CreatedAt = Set<members::created_at>;
type Station = St::Station;
type Text = St::Text;
}
pub struct SetStation<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStation<St> {}
impl<St: State> State for SetStation<St> {
type CreatedAt = St::CreatedAt;
type Station = Set<members::station>;
type Text = St::Text;
}
pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetText<St> {}
impl<St: State> State for SetText<St> {
type CreatedAt = St::CreatedAt;
type Station = St::Station;
type Text = Set<members::text>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct station(());
pub struct text(());
}
}
pub struct CommentBuilder<St: comment_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<Vec<comment::Mention<S>>>,
Option<comment::Gif<S>>,
Option<StationInfo<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl Comment<DefaultStr> {
pub fn new() -> CommentBuilder<comment_state::Empty, DefaultStr> {
CommentBuilder::new()
}
}
impl<S: BosStr> Comment<S> {
pub fn builder() -> CommentBuilder<comment_state::Empty, S> {
CommentBuilder::builder()
}
}
impl CommentBuilder<comment_state::Empty, DefaultStr> {
pub fn new() -> Self {
CommentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> CommentBuilder<comment_state::Empty, S> {
pub fn builder() -> Self {
CommentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CommentBuilder<St, S>
where
St: comment_state::State,
St::CreatedAt: comment_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> CommentBuilder<comment_state::SetCreatedAt<St>, S> {
self._fields.0 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St: comment_state::State, S: BosStr> CommentBuilder<St, S> {
pub fn facets(mut self, value: impl Into<Option<Vec<comment::Mention<S>>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_facets(mut self, value: Option<Vec<comment::Mention<S>>>) -> Self {
self._fields.1 = value;
self
}
}
impl<St: comment_state::State, S: BosStr> CommentBuilder<St, S> {
pub fn gif(mut self, value: impl Into<Option<comment::Gif<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_gif(mut self, value: Option<comment::Gif<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<St, S: BosStr> CommentBuilder<St, S>
where
St: comment_state::State,
St::Station: comment_state::IsUnset,
{
pub fn station(
mut self,
value: impl Into<StationInfo<S>>,
) -> CommentBuilder<comment_state::SetStation<St>, S> {
self._fields.3 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CommentBuilder<St, S>
where
St: comment_state::State,
St::Text: comment_state::IsUnset,
{
pub fn text(mut self, value: impl Into<S>) -> CommentBuilder<comment_state::SetText<St>, S> {
self._fields.4 = Option::Some(value.into());
CommentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> CommentBuilder<St, S>
where
St: comment_state::State,
St::CreatedAt: comment_state::IsSet,
St::Station: comment_state::IsSet,
St::Text: comment_state::IsSet,
{
pub fn build(self) -> Comment<S> {
Comment {
created_at: self._fields.0.unwrap(),
facets: self._fields.1,
gif: self._fields.2,
station: self._fields.3.unwrap(),
text: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Comment<S> {
Comment {
created_at: self._fields.0.unwrap(),
facets: self._fields.1,
gif: self._fields.2,
station: self._fields.3.unwrap(),
text: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod mention_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 ByteEnd;
type ByteStart;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ByteEnd = Unset;
type ByteStart = Unset;
type Did = Unset;
}
pub struct SetByteEnd<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetByteEnd<St> {}
impl<St: State> State for SetByteEnd<St> {
type ByteEnd = Set<members::byte_end>;
type ByteStart = St::ByteStart;
type Did = St::Did;
}
pub struct SetByteStart<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetByteStart<St> {}
impl<St: State> State for SetByteStart<St> {
type ByteEnd = St::ByteEnd;
type ByteStart = Set<members::byte_start>;
type Did = St::Did;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type ByteEnd = St::ByteEnd;
type ByteStart = St::ByteStart;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct byte_end(());
pub struct byte_start(());
pub struct did(());
}
}
pub struct MentionBuilder<St: mention_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>, Option<Did<S>>),
_type: PhantomData<fn() -> S>,
}
impl Mention<DefaultStr> {
pub fn new() -> MentionBuilder<mention_state::Empty, DefaultStr> {
MentionBuilder::new()
}
}
impl<S: BosStr> Mention<S> {
pub fn builder() -> MentionBuilder<mention_state::Empty, S> {
MentionBuilder::builder()
}
}
impl MentionBuilder<mention_state::Empty, DefaultStr> {
pub fn new() -> Self {
MentionBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> MentionBuilder<mention_state::Empty, S> {
pub fn builder() -> Self {
MentionBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> MentionBuilder<St, S>
where
St: mention_state::State,
St::ByteEnd: mention_state::IsUnset,
{
pub fn byte_end(
mut self,
value: impl Into<i64>,
) -> MentionBuilder<mention_state::SetByteEnd<St>, S> {
self._fields.0 = Option::Some(value.into());
MentionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> MentionBuilder<St, S>
where
St: mention_state::State,
St::ByteStart: mention_state::IsUnset,
{
pub fn byte_start(
mut self,
value: impl Into<i64>,
) -> MentionBuilder<mention_state::SetByteStart<St>, S> {
self._fields.1 = Option::Some(value.into());
MentionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> MentionBuilder<St, S>
where
St: mention_state::State,
St::Did: mention_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> MentionBuilder<mention_state::SetDid<St>, S> {
self._fields.2 = Option::Some(value.into());
MentionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> MentionBuilder<St, S>
where
St: mention_state::State,
St::ByteEnd: mention_state::IsSet,
St::ByteStart: mention_state::IsSet,
St::Did: mention_state::IsSet,
{
pub fn build(self) -> Mention<S> {
Mention {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.unwrap(),
did: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Mention<S> {
Mention {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.unwrap(),
did: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}