proto_blue_api/generated/chat/bsky/actor/
exportAccountData.rs1use serde::{Deserialize, Serialize};
5
6#[derive(Debug, thiserror::Error)]
8pub enum CallError {
9 #[error("{0}")]
10 Xrpc(proto_blue_xrpc::XrpcError),
11 #[error(transparent)]
12 Transport(#[from] proto_blue_xrpc::Error),
13 #[error(transparent)]
14 Json(#[from] serde_json::Error),
15}
16
17fn map_xrpc_error(err: proto_blue_xrpc::XrpcError) -> CallError {
18 CallError::Xrpc(err)
19}
20
21pub async fn call(
23 client: &proto_blue_xrpc::XrpcClient,
24 opts: Option<&proto_blue_xrpc::CallOptions>,
25) -> Result<serde_json::Value, CallError> {
26 let response = match client.query("chat.bsky.actor.exportAccountData", None, opts).await {
27 Ok(r) => r,
28 Err(proto_blue_xrpc::Error::Xrpc(x)) => return Err(map_xrpc_error(x)),
29 Err(e) => return Err(CallError::Transport(e)),
30 };
31 Ok(response.data)
32}
33
34#[cfg(feature = "server")]
36pub fn register<F, Fut>(
37server: proto_blue_xrpc::XrpcServer,
38handler: F,
39) -> proto_blue_xrpc::XrpcServer
40where
41 F: Fn(proto_blue_xrpc::HandlerContext) -> Fut + Send + Sync + 'static,
42 Fut: std::future::Future<Output = Result<serde_json::Value, proto_blue_xrpc::XrpcServerError>> + Send + 'static,
43{
44 let handler = std::sync::Arc::new(handler);
45 server.query("chat.bsky.actor.exportAccountData", move |ctx| {
46 let handler = handler.clone();
47 async move {
48 let out = handler(ctx).await?;
49 Ok::<_, proto_blue_xrpc::XrpcServerError>(out)
50 }
51 })
52}
53