// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: tools.ozone.safelink.addRule // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, bon::Builder )] #[serde(rename_all = "camelCase")] #[builder(start_fn = new)] pub struct AddRule<'a> { #[serde(borrow)] pub action: crate::tools_ozone::safelink::ActionType<'a>, ///Optional comment about the decision #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] #[builder(into)] pub comment: std::option::Option>, ///Author DID. Only respected when using admin auth #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub created_by: std::option::Option>, #[serde(borrow)] pub pattern: crate::tools_ozone::safelink::PatternType<'a>, #[serde(borrow)] pub reason: crate::tools_ozone::safelink::ReasonType<'a>, ///The URL or domain to apply the rule to #[serde(borrow)] #[builder(into)] pub url: jacquard_common::CowStr<'a>, #[serde(flatten)] #[serde(borrow)] #[builder(default)] pub extra_data: ::std::collections::BTreeMap< ::jacquard_common::smol_str::SmolStr, ::jacquard_common::types::value::Data<'a>, >, } impl jacquard_common::IntoStatic for AddRule<'_> { type Output = AddRule<'static>; fn into_static(self) -> Self::Output { AddRule { action: self.action.into_static(), comment: self.comment.into_static(), created_by: self.created_by.into_static(), pattern: self.pattern.into_static(), reason: self.reason.into_static(), url: self.url.into_static(), extra_data: self.extra_data.into_static(), } } } #[jacquard_derive::lexicon] #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct AddRuleOutput<'a> { #[serde(flatten)] #[serde(borrow)] pub value: crate::tools_ozone::safelink::Event<'a>, } impl jacquard_common::IntoStatic for AddRuleOutput<'_> { type Output = AddRuleOutput<'static>; fn into_static(self) -> Self::Output { AddRuleOutput { value: self.value.into_static(), extra_data: self.extra_data.into_static(), } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum AddRuleError<'a> { ///The provided URL is invalid #[serde(rename = "InvalidUrl")] InvalidUrl(std::option::Option), ///A rule for this URL/domain already exists #[serde(rename = "RuleAlreadyExists")] RuleAlreadyExists(std::option::Option), } impl std::fmt::Display for AddRuleError<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::InvalidUrl(msg) => { write!(f, "InvalidUrl")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::RuleAlreadyExists(msg) => { write!(f, "RuleAlreadyExists")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } impl jacquard_common::IntoStatic for AddRuleError<'_> { type Output = AddRuleError<'static>; fn into_static(self) -> Self::Output { match self { AddRuleError::InvalidUrl(v) => AddRuleError::InvalidUrl(v.into_static()), AddRuleError::RuleAlreadyExists(v) => { AddRuleError::RuleAlreadyExists(v.into_static()) } AddRuleError::Unknown(v) => AddRuleError::Unknown(v.into_static()), } } } impl jacquard_common::types::xrpc::XrpcRequest for AddRule<'_> { const NSID: &'static str = "tools.ozone.safelink.addRule"; const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Procedure( "application/json", ); const OUTPUT_ENCODING: &'static str = "application/json"; type Output<'de> = AddRuleOutput<'de>; type Err<'de> = AddRuleError<'de>; }