A better Rust ATProto crate
at lifetimes 6.1 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: place.stream.server.createWebhook 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 bon::Builder, 17 jacquard_derive::IntoStatic 18)] 19#[serde(rename_all = "camelCase")] 20#[builder(start_fn = new)] 21pub struct CreateWebhook<'a> { 22 ///Whether this webhook should be active upon creation. 23 #[serde(skip_serializing_if = "std::option::Option::is_none")] 24 pub active: std::option::Option<bool>, 25 ///A description of what this webhook is used for. 26 #[serde(skip_serializing_if = "std::option::Option::is_none")] 27 #[serde(borrow)] 28 #[builder(into)] 29 pub description: std::option::Option<jacquard_common::CowStr<'a>>, 30 ///The types of events this webhook should receive. 31 #[serde(borrow)] 32 pub events: Vec<jacquard_common::CowStr<'a>>, 33 ///A user-friendly name for this webhook. 34 #[serde(skip_serializing_if = "std::option::Option::is_none")] 35 #[serde(borrow)] 36 #[builder(into)] 37 pub name: std::option::Option<jacquard_common::CowStr<'a>>, 38 ///Text to prepend to webhook messages. 39 #[serde(skip_serializing_if = "std::option::Option::is_none")] 40 #[serde(borrow)] 41 #[builder(into)] 42 pub prefix: std::option::Option<jacquard_common::CowStr<'a>>, 43 ///Text replacement rules for webhook messages. 44 #[serde(skip_serializing_if = "std::option::Option::is_none")] 45 #[serde(borrow)] 46 pub rewrite: std::option::Option<Vec<crate::place_stream::server::RewriteRule<'a>>>, 47 ///Text to append to webhook messages. 48 #[serde(skip_serializing_if = "std::option::Option::is_none")] 49 #[serde(borrow)] 50 #[builder(into)] 51 pub suffix: std::option::Option<jacquard_common::CowStr<'a>>, 52 ///The webhook URL where events will be sent. 53 #[serde(borrow)] 54 pub url: jacquard_common::types::string::Uri<'a>, 55 #[serde(flatten)] 56 #[serde(borrow)] 57 #[builder(default)] 58 pub extra_data: ::std::collections::BTreeMap< 59 ::jacquard_common::smol_str::SmolStr, 60 ::jacquard_common::types::value::Data<'a>, 61 >, 62} 63 64#[jacquard_derive::lexicon] 65#[derive( 66 serde::Serialize, 67 serde::Deserialize, 68 Debug, 69 Clone, 70 PartialEq, 71 Eq, 72 jacquard_derive::IntoStatic 73)] 74#[serde(rename_all = "camelCase")] 75pub struct CreateWebhookOutput<'a> { 76 #[serde(borrow)] 77 pub webhook: crate::place_stream::server::Webhook<'a>, 78} 79 80#[jacquard_derive::open_union] 81#[derive( 82 serde::Serialize, 83 serde::Deserialize, 84 Debug, 85 Clone, 86 PartialEq, 87 Eq, 88 thiserror::Error, 89 miette::Diagnostic 90)] 91#[serde(tag = "error", content = "message")] 92#[serde(bound(deserialize = "'de: 'a"))] 93pub enum CreateWebhookError<'a> { 94 ///The provided webhook URL is invalid or unreachable. 95 #[serde(rename = "InvalidUrl")] 96 InvalidUrl(std::option::Option<String>), 97 ///A webhook with this URL already exists for this user. 98 #[serde(rename = "DuplicateWebhook")] 99 DuplicateWebhook(std::option::Option<String>), 100 ///The user has reached their maximum number of webhooks. 101 #[serde(rename = "TooManyWebhooks")] 102 TooManyWebhooks(std::option::Option<String>), 103} 104 105impl std::fmt::Display for CreateWebhookError<'_> { 106 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 107 match self { 108 Self::InvalidUrl(msg) => { 109 write!(f, "InvalidUrl")?; 110 if let Some(msg) = msg { 111 write!(f, ": {}", msg)?; 112 } 113 Ok(()) 114 } 115 Self::DuplicateWebhook(msg) => { 116 write!(f, "DuplicateWebhook")?; 117 if let Some(msg) = msg { 118 write!(f, ": {}", msg)?; 119 } 120 Ok(()) 121 } 122 Self::TooManyWebhooks(msg) => { 123 write!(f, "TooManyWebhooks")?; 124 if let Some(msg) = msg { 125 write!(f, ": {}", msg)?; 126 } 127 Ok(()) 128 } 129 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 130 } 131 } 132} 133 134impl jacquard_common::IntoStatic for CreateWebhookError<'_> { 135 type Output = CreateWebhookError<'static>; 136 fn into_static(self) -> Self::Output { 137 match self { 138 CreateWebhookError::InvalidUrl(v) => { 139 CreateWebhookError::InvalidUrl(v.into_static()) 140 } 141 CreateWebhookError::DuplicateWebhook(v) => { 142 CreateWebhookError::DuplicateWebhook(v.into_static()) 143 } 144 CreateWebhookError::TooManyWebhooks(v) => { 145 CreateWebhookError::TooManyWebhooks(v.into_static()) 146 } 147 CreateWebhookError::Unknown(v) => { 148 CreateWebhookError::Unknown(v.into_static()) 149 } 150 } 151 } 152} 153 154///Response type for 155///place.stream.server.createWebhook 156pub struct CreateWebhookResponse; 157impl jacquard_common::xrpc::XrpcResp for CreateWebhookResponse { 158 const NSID: &'static str = "place.stream.server.createWebhook"; 159 const ENCODING: &'static str = "application/json"; 160 type Output<'de> = CreateWebhookOutput<'de>; 161 type Err<'de> = CreateWebhookError<'de>; 162} 163 164impl<'de> jacquard_common::xrpc::XrpcRequest<'de> for CreateWebhook<'de> { 165 const NSID: &'static str = "place.stream.server.createWebhook"; 166 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 167 "application/json", 168 ); 169 type Response = CreateWebhookResponse; 170} 171 172///Endpoint type for 173///place.stream.server.createWebhook 174pub struct CreateWebhookRequest; 175impl jacquard_common::xrpc::XrpcEndpoint for CreateWebhookRequest { 176 const PATH: &'static str = "/xrpc/place.stream.server.createWebhook"; 177 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( 178 "application/json", 179 ); 180 type Request<'de> = CreateWebhook<'de>; 181 type Response = CreateWebhookResponse; 182}