Skip to main content

jacquard_api/sh_tangled/
owner.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.tangled.owner
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::Did;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17
18#[lexicon]
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct OwnerOutput<'a> {
22    #[serde(borrow)]
23    pub owner: Did<'a>,
24}
25
26
27#[open_union]
28#[derive(
29    Serialize,
30    Deserialize,
31    Debug,
32    Clone,
33    PartialEq,
34    Eq,
35    thiserror::Error,
36    miette::Diagnostic,
37    IntoStatic
38)]
39
40#[serde(tag = "error", content = "message")]
41#[serde(bound(deserialize = "'de: 'a"))]
42pub enum OwnerError<'a> {
43    /// Owner is not set for this service
44    #[serde(rename = "OwnerNotFound")]
45    OwnerNotFound(Option<CowStr<'a>>),
46}
47
48impl core::fmt::Display for OwnerError<'_> {
49    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
50        match self {
51            Self::OwnerNotFound(msg) => {
52                write!(f, "OwnerNotFound")?;
53                if let Some(msg) = msg {
54                    write!(f, ": {}", msg)?;
55                }
56                Ok(())
57            }
58            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
59        }
60    }
61}
62
63/// XRPC request marker type.
64
65#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
66pub struct Owner;
67/// Response type for sh.tangled.owner
68pub struct OwnerResponse;
69impl jacquard_common::xrpc::XrpcResp for OwnerResponse {
70    const NSID: &'static str = "sh.tangled.owner";
71    const ENCODING: &'static str = "application/json";
72    type Output<'de> = OwnerOutput<'de>;
73    type Err<'de> = OwnerError<'de>;
74}
75
76impl jacquard_common::xrpc::XrpcRequest for Owner {
77    const NSID: &'static str = "sh.tangled.owner";
78    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
79    type Response = OwnerResponse;
80}
81
82/// Endpoint type for sh.tangled.owner
83pub struct OwnerRequest;
84impl jacquard_common::xrpc::XrpcEndpoint for OwnerRequest {
85    const PATH: &'static str = "/xrpc/sh.tangled.owner";
86    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
87    type Request<'de> = Owner;
88    type Response = OwnerResponse;
89}