Skip to main content

proto_blue_api/generated/com/atproto/temp/
checkSignupQueue.rs

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