Skip to main content

proto_blue_api/generated/com/atproto/server/
checkAccountStatus.rs

1// Generated by atproto-codegen. Do not edit.
2//! Lexicon: com.atproto.server.checkAccountStatus
3
4use serde::{Deserialize, Serialize};
5
6/// Returns the status of an account, especially as pertaining to import or recovery. Can be called many times over the course of an account migration. Requires auth and can only be called pertaining to oneself.
7/// XRPC Query: com.atproto.server.checkAccountStatus
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Output {
11    pub activated: bool,
12    pub expected_blobs: i64,
13    pub imported_blobs: i64,
14    pub indexed_records: i64,
15    pub private_state_values: i64,
16    pub repo_blocks: i64,
17    pub repo_commit: String,
18    pub repo_rev: String,
19    pub valid_did: bool,
20}
21
22/// Errors a `call()` on this method can return.
23#[derive(Debug, thiserror::Error)]
24pub enum CallError {
25    #[error("{0}")]
26    Xrpc(proto_blue_xrpc::XrpcError),
27    #[error(transparent)]
28    Transport(#[from] proto_blue_xrpc::Error),
29    #[error(transparent)]
30    Json(#[from] serde_json::Error),
31}
32
33fn map_xrpc_error(err: proto_blue_xrpc::XrpcError) -> CallError {
34    CallError::Xrpc(err)
35}
36
37/// Execute the query.
38pub async fn call(
39    client: &proto_blue_xrpc::XrpcClient,
40    opts: Option<&proto_blue_xrpc::CallOptions>,
41) -> Result<Output, CallError> {
42    let response = match client.query("com.atproto.server.checkAccountStatus", None, opts).await {
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 [`XrpcServer`].
51#[cfg(feature = "server")]
52pub fn register<F, Fut>(
53server: proto_blue_xrpc::XrpcServer,
54handler: 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>> + Send + 'static,
59{
60    let handler = std::sync::Arc::new(handler);
61    server.query("com.atproto.server.checkAccountStatus", move |ctx| {
62        let handler = handler.clone();
63        async move {
64            let out = handler(ctx).await?;
65            let value = serde_json::to_value(&out)
66                .map_err(|e| proto_blue_xrpc::XrpcServerError::new(proto_blue_xrpc::ResponseType::InternalServerError, format!("output serialize: {e}")))?;
67            Ok::<_, proto_blue_xrpc::XrpcServerError>(value)
68        }
69    })
70}
71