A better Rust ATProto crate
at oauth 4.1 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: tools.ozone.safelink.removeRule 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)] 18#[serde(rename_all = "camelCase")] 19#[builder(start_fn = new)] 20pub struct RemoveRule<'a> { 21 ///Optional comment about why the rule is being removed 22 #[serde(skip_serializing_if = "std::option::Option::is_none")] 23 #[serde(borrow)] 24 #[builder(into)] 25 pub comment: std::option::Option<jacquard_common::CowStr<'a>>, 26 ///Optional DID of the user. Only respected when using admin auth. 27 #[serde(skip_serializing_if = "std::option::Option::is_none")] 28 #[serde(borrow)] 29 pub created_by: std::option::Option<jacquard_common::types::string::Did<'a>>, 30 #[serde(borrow)] 31 pub pattern: crate::tools_ozone::safelink::PatternType<'a>, 32 ///The URL or domain to remove the rule for 33 #[serde(borrow)] 34 #[builder(into)] 35 pub url: jacquard_common::CowStr<'a>, 36 #[serde(flatten)] 37 #[serde(borrow)] 38 #[builder(default)] 39 pub extra_data: ::std::collections::BTreeMap< 40 ::jacquard_common::smol_str::SmolStr, 41 ::jacquard_common::types::value::Data<'a>, 42 >, 43} 44 45impl jacquard_common::IntoStatic for RemoveRule<'_> { 46 type Output = RemoveRule<'static>; 47 fn into_static(self) -> Self::Output { 48 RemoveRule { 49 comment: self.comment.into_static(), 50 created_by: self.created_by.into_static(), 51 pattern: self.pattern.into_static(), 52 url: self.url.into_static(), 53 extra_data: self.extra_data.into_static(), 54 } 55 } 56} 57 58#[jacquard_derive::lexicon] 59#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 60#[serde(rename_all = "camelCase")] 61pub struct RemoveRuleOutput<'a> { 62 #[serde(flatten)] 63 #[serde(borrow)] 64 pub value: crate::tools_ozone::safelink::Event<'a>, 65} 66 67impl jacquard_common::IntoStatic for RemoveRuleOutput<'_> { 68 type Output = RemoveRuleOutput<'static>; 69 fn into_static(self) -> Self::Output { 70 RemoveRuleOutput { 71 value: self.value.into_static(), 72 extra_data: self.extra_data.into_static(), 73 } 74 } 75} 76 77#[jacquard_derive::open_union] 78#[derive( 79 serde::Serialize, 80 serde::Deserialize, 81 Debug, 82 Clone, 83 PartialEq, 84 Eq, 85 thiserror::Error, 86 miette::Diagnostic 87)] 88#[serde(tag = "error", content = "message")] 89#[serde(bound(deserialize = "'de: 'a"))] 90pub enum RemoveRuleError<'a> { 91 ///No active rule found for this URL/domain 92 #[serde(rename = "RuleNotFound")] 93 RuleNotFound(std::option::Option<String>), 94} 95 96impl std::fmt::Display for RemoveRuleError<'_> { 97 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 98 match self { 99 Self::RuleNotFound(msg) => { 100 write!(f, "RuleNotFound")?; 101 if let Some(msg) = msg { 102 write!(f, ": {}", msg)?; 103 } 104 Ok(()) 105 } 106 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 107 } 108 } 109} 110 111impl jacquard_common::IntoStatic for RemoveRuleError<'_> { 112 type Output = RemoveRuleError<'static>; 113 fn into_static(self) -> Self::Output { 114 match self { 115 RemoveRuleError::RuleNotFound(v) => { 116 RemoveRuleError::RuleNotFound(v.into_static()) 117 } 118 RemoveRuleError::Unknown(v) => RemoveRuleError::Unknown(v.into_static()), 119 } 120 } 121} 122 123impl jacquard_common::types::xrpc::XrpcRequest for RemoveRule<'_> { 124 const NSID: &'static str = "tools.ozone.safelink.removeRule"; 125 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Procedure( 126 "application/json", 127 ); 128 const OUTPUT_ENCODING: &'static str = "application/json"; 129 type Output<'de> = RemoveRuleOutput<'de>; 130 type Err<'de> = RemoveRuleError<'de>; 131}