A better Rust ATProto crate
at oauth 5.0 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: chat.bsky.convo.addReaction 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 AddReaction<'a> { 21 #[serde(borrow)] 22 #[builder(into)] 23 pub convo_id: jacquard_common::CowStr<'a>, 24 #[serde(borrow)] 25 #[builder(into)] 26 pub message_id: jacquard_common::CowStr<'a>, 27 #[serde(borrow)] 28 #[builder(into)] 29 pub value: jacquard_common::CowStr<'a>, 30 #[serde(flatten)] 31 #[serde(borrow)] 32 #[builder(default)] 33 pub extra_data: ::std::collections::BTreeMap< 34 ::jacquard_common::smol_str::SmolStr, 35 ::jacquard_common::types::value::Data<'a>, 36 >, 37} 38 39impl jacquard_common::IntoStatic for AddReaction<'_> { 40 type Output = AddReaction<'static>; 41 fn into_static(self) -> Self::Output { 42 AddReaction { 43 convo_id: self.convo_id.into_static(), 44 message_id: self.message_id.into_static(), 45 value: self.value.into_static(), 46 extra_data: self.extra_data.into_static(), 47 } 48 } 49} 50 51#[jacquard_derive::lexicon] 52#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] 53#[serde(rename_all = "camelCase")] 54pub struct AddReactionOutput<'a> { 55 #[serde(borrow)] 56 pub message: crate::chat_bsky::convo::MessageView<'a>, 57} 58 59impl jacquard_common::IntoStatic for AddReactionOutput<'_> { 60 type Output = AddReactionOutput<'static>; 61 fn into_static(self) -> Self::Output { 62 AddReactionOutput { 63 message: self.message.into_static(), 64 extra_data: self.extra_data.into_static(), 65 } 66 } 67} 68 69#[jacquard_derive::open_union] 70#[derive( 71 serde::Serialize, 72 serde::Deserialize, 73 Debug, 74 Clone, 75 PartialEq, 76 Eq, 77 thiserror::Error, 78 miette::Diagnostic 79)] 80#[serde(tag = "error", content = "message")] 81#[serde(bound(deserialize = "'de: 'a"))] 82pub enum AddReactionError<'a> { 83 ///Indicates that the message has been deleted and reactions can no longer be added/removed. 84 #[serde(rename = "ReactionMessageDeleted")] 85 ReactionMessageDeleted(std::option::Option<String>), 86 ///Indicates that the message has the maximum number of reactions allowed for a single user, and the requested reaction wasn't yet present. If it was already present, the request will not fail since it is idempotent. 87 #[serde(rename = "ReactionLimitReached")] 88 ReactionLimitReached(std::option::Option<String>), 89 ///Indicates the value for the reaction is not acceptable. In general, this means it is not an emoji. 90 #[serde(rename = "ReactionInvalidValue")] 91 ReactionInvalidValue(std::option::Option<String>), 92} 93 94impl std::fmt::Display for AddReactionError<'_> { 95 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 96 match self { 97 Self::ReactionMessageDeleted(msg) => { 98 write!(f, "ReactionMessageDeleted")?; 99 if let Some(msg) = msg { 100 write!(f, ": {}", msg)?; 101 } 102 Ok(()) 103 } 104 Self::ReactionLimitReached(msg) => { 105 write!(f, "ReactionLimitReached")?; 106 if let Some(msg) = msg { 107 write!(f, ": {}", msg)?; 108 } 109 Ok(()) 110 } 111 Self::ReactionInvalidValue(msg) => { 112 write!(f, "ReactionInvalidValue")?; 113 if let Some(msg) = msg { 114 write!(f, ": {}", msg)?; 115 } 116 Ok(()) 117 } 118 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 119 } 120 } 121} 122 123impl jacquard_common::IntoStatic for AddReactionError<'_> { 124 type Output = AddReactionError<'static>; 125 fn into_static(self) -> Self::Output { 126 match self { 127 AddReactionError::ReactionMessageDeleted(v) => { 128 AddReactionError::ReactionMessageDeleted(v.into_static()) 129 } 130 AddReactionError::ReactionLimitReached(v) => { 131 AddReactionError::ReactionLimitReached(v.into_static()) 132 } 133 AddReactionError::ReactionInvalidValue(v) => { 134 AddReactionError::ReactionInvalidValue(v.into_static()) 135 } 136 AddReactionError::Unknown(v) => AddReactionError::Unknown(v.into_static()), 137 } 138 } 139} 140 141impl jacquard_common::types::xrpc::XrpcRequest for AddReaction<'_> { 142 const NSID: &'static str = "chat.bsky.convo.addReaction"; 143 const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Procedure( 144 "application/json", 145 ); 146 const OUTPUT_ENCODING: &'static str = "application/json"; 147 type Output<'de> = AddReactionOutput<'de>; 148 type Err<'de> = AddReactionError<'de>; 149}