Something went wrong. Try again.
atproto made easy crates.io/crates/jacquard
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845// @generated by jacquard-lexicon. DO NOT EDIT.//// Lexicon: place.stream.server.defs//// This file was automatically generated from Lexicon schemas.// Any manual changes will be overwritten on the next regeneration.
pub mod create_webhook;pub mod delete_webhook;pub mod get_server_time;pub mod get_webhook;pub mod list_webhooks;pub mod settings;pub mod update_webhook;
#[allow(unused_imports)]use alloc::collections::BTreeMap;
#[allow(unused_imports)]use core::marker::PhantomData;use jacquard_common::CowStr;
#[allow(unused_imports)]use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;use jacquard_common::types::string::{Datetime, UriValue};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::place_stream::server;
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]#[serde(rename_all = "camelCase")]pub struct RewriteRule<'a> { ///Text to search for and replace. #[serde(borrow)] pub from: CowStr<'a>, ///Text to replace with. #[serde(borrow)] pub to: CowStr<'a>,}
/// A webhook configuration for receiving Streamplace events.
#[lexicon]#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]#[serde(rename_all = "camelCase")]pub struct Webhook<'a> { ///Whether this webhook is currently active. pub active: bool, ///When this webhook was created. pub created_at: Datetime, ///A description of what this webhook is used for. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub description: Option<CowStr<'a>>, ///Number of consecutive errors for this webhook. #[serde(skip_serializing_if = "Option::is_none")] pub error_count: Option<i64>, ///The types of events this webhook should receive. #[serde(borrow)] pub events: Vec<CowStr<'a>>, ///Unique identifier for this webhook. #[serde(borrow)] pub id: CowStr<'a>, ///When this webhook was last triggered. #[serde(skip_serializing_if = "Option::is_none")] pub last_triggered: Option<Datetime>, ///Words to filter out from chat messages. Messages containing any of these words will not be forwarded. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub mute_words: Option<Vec<CowStr<'a>>>, ///A user-friendly name for this webhook. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub name: Option<CowStr<'a>>, ///Text to prepend to webhook messages. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub prefix: Option<CowStr<'a>>, ///Text replacement rules for webhook messages. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub rewrite: Option<Vec<server::RewriteRule<'a>>>, ///Text to append to webhook messages. #[serde(skip_serializing_if = "Option::is_none")] #[serde(borrow)] pub suffix: Option<CowStr<'a>>, ///When this webhook was last updated. #[serde(skip_serializing_if = "Option::is_none")] pub updated_at: Option<Datetime>, ///The webhook URL where events will be sent. #[serde(borrow)] pub url: UriValue<'a>,}
impl<'a> LexiconSchema for RewriteRule<'a> { fn nsid() -> &'static str { "place.stream.server.defs" } fn def_name() -> &'static str { "rewriteRule" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_place_stream_server_defs() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.from; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("from"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } { let value = &self.from; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) < 1usize { return Err(ConstraintError::MinLength { path: ValidationPath::from_field("from"), min: 1usize, actual: <str>::len(value.as_ref()), }); } } { let value = &self.to; #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("to"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
impl<'a> LexiconSchema for Webhook<'a> { fn nsid() -> &'static str { "place.stream.server.defs" } fn def_name() -> &'static str { "webhook" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_place_stream_server_defs() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 500usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("description"), max: 500usize, actual: <str>::len(value.as_ref()), }); } } if let Some(ref value) = self.name { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("name"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } if let Some(ref value) = self.prefix { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("prefix"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } if let Some(ref value) = self.suffix { #[allow(unused_comparisons)] if <str>::len(value.as_ref()) > 100usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("suffix"), max: 100usize, actual: <str>::len(value.as_ref()), }); } } Ok(()) }}
fn lexicon_doc_place_stream_server_defs() -> 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("place.stream.server.defs"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("rewriteRule"), LexUserType::Object(LexObject { required: Some( vec![SmolStr::new_static("from"), SmolStr::new_static("to")], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("from"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Text to search for and replace."), ), min_length: Some(1usize), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("to"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Text to replace with."), ), max_length: Some(100usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("webhook"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A webhook configuration for receiving Streamplace events.", ), ), required: Some( vec![ SmolStr::new_static("id"), SmolStr::new_static("url"), SmolStr::new_static("events"), SmolStr::new_static("active"), SmolStr::new_static("createdAt") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("active"), LexObjectProperty::Boolean(LexBoolean { ..Default::default() }), ); map.insert( SmolStr::new_static("createdAt"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("When this webhook was created."), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("description"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "A description of what this webhook is used for.", ), ), max_length: Some(500usize), ..Default::default() }), ); map.insert( SmolStr::new_static("errorCount"), LexObjectProperty::Integer(LexInteger { ..Default::default() }), ); map.insert( SmolStr::new_static("events"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "The types of events this webhook should receive.", ), ), items: LexArrayItem::String(LexString { ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("id"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Unique identifier for this webhook."), ), ..Default::default() }), ); map.insert( SmolStr::new_static("lastTriggered"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("When this webhook was last triggered."), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("muteWords"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "Words to filter out from chat messages. Messages containing any of these words will not be forwarded.", ), ), items: LexArrayItem::String(LexString { max_length: Some(100usize), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("name"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("A user-friendly name for this webhook."), ), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("prefix"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Text to prepend to webhook messages."), ), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("rewrite"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "Text replacement rules for webhook messages.", ), ), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("#rewriteRule"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("suffix"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("Text to append to webhook messages."), ), max_length: Some(100usize), ..Default::default() }), ); map.insert( SmolStr::new_static("updatedAt"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static("When this webhook was last updated."), ), format: Some(LexStringFormat::Datetime), ..Default::default() }), ); map.insert( SmolStr::new_static("url"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "The webhook URL where events will be sent.", ), ), format: Some(LexStringFormat::Uri), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() }}
pub mod webhook_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Id; type Events; type CreatedAt; type Active; type Url; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Id = Unset; type Events = Unset; type CreatedAt = Unset; type Active = Unset; type Url = Unset; } ///State transition - sets the `id` field to Set pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetId<S> {} impl<S: State> State for SetId<S> { type Id = Set<members::id>; type Events = S::Events; type CreatedAt = S::CreatedAt; type Active = S::Active; type Url = S::Url; } ///State transition - sets the `events` field to Set pub struct SetEvents<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetEvents<S> {} impl<S: State> State for SetEvents<S> { type Id = S::Id; type Events = Set<members::events>; type CreatedAt = S::CreatedAt; type Active = S::Active; type Url = S::Url; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetCreatedAt<S> {} impl<S: State> State for SetCreatedAt<S> { type Id = S::Id; type Events = S::Events; type CreatedAt = Set<members::created_at>; type Active = S::Active; type Url = S::Url; } ///State transition - sets the `active` field to Set pub struct SetActive<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetActive<S> {} impl<S: State> State for SetActive<S> { type Id = S::Id; type Events = S::Events; type CreatedAt = S::CreatedAt; type Active = Set<members::active>; type Url = S::Url; } ///State transition - sets the `url` field to Set pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>); impl<S: State> sealed::Sealed for SetUrl<S> {} impl<S: State> State for SetUrl<S> { type Id = S::Id; type Events = S::Events; type CreatedAt = S::CreatedAt; type Active = S::Active; type Url = Set<members::url>; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `id` field pub struct id(()); ///Marker type for the `events` field pub struct events(()); ///Marker type for the `created_at` field pub struct created_at(()); ///Marker type for the `active` field pub struct active(()); ///Marker type for the `url` field pub struct url(()); }}
/// Builder for constructing an instance of this typepub struct WebhookBuilder<'a, S: webhook_state::State> { _state: PhantomData<fn() -> S>, _fields: ( Option<bool>, Option<Datetime>, Option<CowStr<'a>>, Option<i64>, Option<Vec<CowStr<'a>>>, Option<CowStr<'a>>, Option<Datetime>, Option<Vec<CowStr<'a>>>, Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Vec<server::RewriteRule<'a>>>, Option<CowStr<'a>>, Option<Datetime>, Option<UriValue<'a>>, ), _lifetime: PhantomData<&'a ()>,}
impl<'a> Webhook<'a> { /// Create a new builder for this type pub fn new() -> WebhookBuilder<'a, webhook_state::Empty> { WebhookBuilder::new() }}
impl<'a> WebhookBuilder<'a, webhook_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { WebhookBuilder { _state: PhantomData, _fields: ( None, None, None, None, None, None, None, None, None, None, None, None, None, None, ), _lifetime: PhantomData, } }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::Active: webhook_state::IsUnset,{ /// Set the `active` field (required) pub fn active( mut self, value: impl Into<bool>, ) -> WebhookBuilder<'a, webhook_state::SetActive<S>> { self._fields.0 = Option::Some(value.into()); WebhookBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::CreatedAt: webhook_state::IsUnset,{ /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into<Datetime>, ) -> WebhookBuilder<'a, webhook_state::SetCreatedAt<S>> { self._fields.1 = Option::Some(value.into()); WebhookBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `description` field (optional) pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.2 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.2 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `errorCount` field (optional) pub fn error_count(mut self, value: impl Into<Option<i64>>) -> Self { self._fields.3 = value.into(); self } /// Set the `errorCount` field to an Option value (optional) pub fn maybe_error_count(mut self, value: Option<i64>) -> Self { self._fields.3 = value; self }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::Events: webhook_state::IsUnset,{ /// Set the `events` field (required) pub fn events( mut self, value: impl Into<Vec<CowStr<'a>>>, ) -> WebhookBuilder<'a, webhook_state::SetEvents<S>> { self._fields.4 = Option::Some(value.into()); WebhookBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::Id: webhook_state::IsUnset,{ /// Set the `id` field (required) pub fn id( mut self, value: impl Into<CowStr<'a>>, ) -> WebhookBuilder<'a, webhook_state::SetId<S>> { self._fields.5 = Option::Some(value.into()); WebhookBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `lastTriggered` field (optional) pub fn last_triggered(mut self, value: impl Into<Option<Datetime>>) -> Self { self._fields.6 = value.into(); self } /// Set the `lastTriggered` field to an Option value (optional) pub fn maybe_last_triggered(mut self, value: Option<Datetime>) -> Self { self._fields.6 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `muteWords` field (optional) pub fn mute_words(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self { self._fields.7 = value.into(); self } /// Set the `muteWords` field to an Option value (optional) pub fn maybe_mute_words(mut self, value: Option<Vec<CowStr<'a>>>) -> Self { self._fields.7 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `name` field (optional) pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.8 = value.into(); self } /// Set the `name` field to an Option value (optional) pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.8 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `prefix` field (optional) pub fn prefix(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.9 = value.into(); self } /// Set the `prefix` field to an Option value (optional) pub fn maybe_prefix(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.9 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `rewrite` field (optional) pub fn rewrite( mut self, value: impl Into<Option<Vec<server::RewriteRule<'a>>>>, ) -> Self { self._fields.10 = value.into(); self } /// Set the `rewrite` field to an Option value (optional) pub fn maybe_rewrite(mut self, value: Option<Vec<server::RewriteRule<'a>>>) -> Self { self._fields.10 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `suffix` field (optional) pub fn suffix(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self { self._fields.11 = value.into(); self } /// Set the `suffix` field to an Option value (optional) pub fn maybe_suffix(mut self, value: Option<CowStr<'a>>) -> Self { self._fields.11 = value; self }}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self { self._fields.12 = value.into(); self } /// Set the `updatedAt` field to an Option value (optional) pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self { self._fields.12 = value; self }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::Url: webhook_state::IsUnset,{ /// Set the `url` field (required) pub fn url( mut self, value: impl Into<UriValue<'a>>, ) -> WebhookBuilder<'a, webhook_state::SetUrl<S>> { self._fields.13 = Option::Some(value.into()); WebhookBuilder { _state: PhantomData, _fields: self._fields, _lifetime: PhantomData, } }}
impl<'a, S> WebhookBuilder<'a, S>where S: webhook_state::State, S::Id: webhook_state::IsSet, S::Events: webhook_state::IsSet, S::CreatedAt: webhook_state::IsSet, S::Active: webhook_state::IsSet, S::Url: webhook_state::IsSet,{ /// Build the final struct pub fn build(self) -> Webhook<'a> { Webhook { active: self._fields.0.unwrap(), created_at: self._fields.1.unwrap(), description: self._fields.2, error_count: self._fields.3, events: self._fields.4.unwrap(), id: self._fields.5.unwrap(), last_triggered: self._fields.6, mute_words: self._fields.7, name: self._fields.8, prefix: self._fields.9, rewrite: self._fields.10, suffix: self._fields.11, updated_at: self._fields.12, url: self._fields.13.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: BTreeMap< jacquard_common::deps::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Webhook<'a> { Webhook { active: self._fields.0.unwrap(), created_at: self._fields.1.unwrap(), description: self._fields.2, error_count: self._fields.3, events: self._fields.4.unwrap(), id: self._fields.5.unwrap(), last_triggered: self._fields.6, mute_words: self._fields.7, name: self._fields.8, prefix: self._fields.9, rewrite: self._fields.10, suffix: self._fields.11, updated_at: self._fields.12, url: self._fields.13.unwrap(), extra_data: Some(extra_data), } }}