// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: com.atproto.server.refreshSession // // 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, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct RefreshSessionOutput<'a> { #[serde(borrow)] pub access_jwt: jacquard_common::CowStr<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub active: std::option::Option, #[serde(borrow)] pub did: jacquard_common::types::string::Did<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub did_doc: std::option::Option>, #[serde(borrow)] pub handle: jacquard_common::types::string::Handle<'a>, #[serde(borrow)] pub refresh_jwt: jacquard_common::CowStr<'a>, /// Hosting status of the account. If not specified, then assume 'active'. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub status: std::option::Option>, } /// Hosting status of the account. If not specified, then assume 'active'. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum RefreshSessionOutputStatus<'a> { Takendown, Suspended, Deactivated, Other(jacquard_common::CowStr<'a>), } impl<'a> RefreshSessionOutputStatus<'a> { pub fn as_str(&self) -> &str { match self { Self::Takendown => "takendown", Self::Suspended => "suspended", Self::Deactivated => "deactivated", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for RefreshSessionOutputStatus<'a> { fn from(s: &'a str) -> Self { match s { "takendown" => Self::Takendown, "suspended" => Self::Suspended, "deactivated" => Self::Deactivated, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for RefreshSessionOutputStatus<'a> { fn from(s: String) -> Self { match s.as_str() { "takendown" => Self::Takendown, "suspended" => Self::Suspended, "deactivated" => Self::Deactivated, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for RefreshSessionOutputStatus<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for RefreshSessionOutputStatus<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for RefreshSessionOutputStatus<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for RefreshSessionOutputStatus<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for RefreshSessionOutputStatus<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for RefreshSessionOutputStatus<'_> { type Output = RefreshSessionOutputStatus<'static>; fn into_static(self) -> Self::Output { match self { RefreshSessionOutputStatus::Takendown => { RefreshSessionOutputStatus::Takendown } RefreshSessionOutputStatus::Suspended => { RefreshSessionOutputStatus::Suspended } RefreshSessionOutputStatus::Deactivated => { RefreshSessionOutputStatus::Deactivated } RefreshSessionOutputStatus::Other(v) => { RefreshSessionOutputStatus::Other(v.into_static()) } } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, jacquard_derive::IntoStatic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum RefreshSessionError<'a> { #[serde(rename = "AccountTakedown")] AccountTakedown(std::option::Option>), } impl core::fmt::Display for RefreshSessionError<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::AccountTakedown(msg) => { write!(f, "AccountTakedown")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } /// XRPC request marker type #[derive( Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, jacquard_derive::IntoStatic )] pub struct RefreshSession; /// Response type for ///com.atproto.server.refreshSession pub struct RefreshSessionResponse; impl jacquard_common::xrpc::XrpcResp for RefreshSessionResponse { const NSID: &'static str = "com.atproto.server.refreshSession"; const ENCODING: &'static str = "application/json"; type Output<'de> = RefreshSessionOutput<'de>; type Err<'de> = RefreshSessionError<'de>; } impl jacquard_common::xrpc::XrpcRequest for RefreshSession { const NSID: &'static str = "com.atproto.server.refreshSession"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( "application/json", ); type Response = RefreshSessionResponse; } /// Endpoint type for ///com.atproto.server.refreshSession pub struct RefreshSessionRequest; impl jacquard_common::xrpc::XrpcEndpoint for RefreshSessionRequest { const PATH: &'static str = "/xrpc/com.atproto.server.refreshSession"; const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure( "application/json", ); type Request<'de> = RefreshSession; type Response = RefreshSessionResponse; }