Skip to main content

proto_blue_api/generated/tools/ozone/server/
getConfig.rs

1// Generated by atproto-codegen. Do not edit.
2//! Lexicon: tools.ozone.server.getConfig
3
4use serde::{Deserialize, Serialize};
5
6/// Get details about ozone's server configuration.
7/// XRPC Query: tools.ozone.server.getConfig
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Output {
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub appview: Option<ServiceConfig>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub blob_divert: Option<ServiceConfig>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub chat: Option<ServiceConfig>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub pds: Option<ServiceConfig>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub verifier_did: Option<String>,
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub viewer: Option<ViewerConfig>,
23}
24
25/// Errors a `call()` on this method can return.
26#[derive(Debug, thiserror::Error)]
27pub enum CallError {
28    #[error("{0}")]
29    Xrpc(proto_blue_xrpc::XrpcError),
30    #[error(transparent)]
31    Transport(#[from] proto_blue_xrpc::Error),
32    #[error(transparent)]
33    Json(#[from] serde_json::Error),
34}
35
36fn map_xrpc_error(err: proto_blue_xrpc::XrpcError) -> CallError {
37    CallError::Xrpc(err)
38}
39
40/// Execute the query.
41pub async fn call(
42    client: &proto_blue_xrpc::XrpcClient,
43    opts: Option<&proto_blue_xrpc::CallOptions>,
44) -> Result<Output, CallError> {
45    let response = match client.query("tools.ozone.server.getConfig", None, opts).await {
46        Ok(r) => r,
47        Err(proto_blue_xrpc::Error::Xrpc(x)) => return Err(map_xrpc_error(x)),
48        Err(e) => return Err(CallError::Transport(e)),
49    };
50    Ok(serde_json::from_value(response.data)?)
51}
52
53/// Register a typed handler for this method on an [`XrpcServer`].
54#[cfg(feature = "server")]
55pub fn register<F, Fut>(
56server: proto_blue_xrpc::XrpcServer,
57handler: F,
58) -> proto_blue_xrpc::XrpcServer
59where
60    F: Fn(proto_blue_xrpc::HandlerContext) -> Fut + Send + Sync + 'static,
61    Fut: std::future::Future<Output = Result<Output, proto_blue_xrpc::XrpcServerError>> + Send + 'static,
62{
63    let handler = std::sync::Arc::new(handler);
64    server.query("tools.ozone.server.getConfig", move |ctx| {
65        let handler = handler.clone();
66        async move {
67            let out = handler(ctx).await?;
68            let value = serde_json::to_value(&out)
69                .map_err(|e| proto_blue_xrpc::XrpcServerError::new(proto_blue_xrpc::ResponseType::InternalServerError, format!("output serialize: {e}")))?;
70            Ok::<_, proto_blue_xrpc::XrpcServerError>(value)
71        }
72    })
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(rename_all = "camelCase")]
77pub struct ServiceConfig {
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub url: Option<String>,
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(rename_all = "camelCase")]
84pub struct ViewerConfig {
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub role: Option<String>,
87}
88