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