Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
oestradiol committed Sep 19, 2024
1 parent aea4389 commit 4a9a4de
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 17 deletions.
36 changes: 29 additions & 7 deletions atrium-xrpc/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ pub trait HttpClient {
fn send_http(
&self,
request: Request<Vec<u8>>,
) -> impl Future<Output = core::result::Result<Response<Vec<u8>>, Box<dyn std::error::Error + Send + Sync + 'static>>>;
) -> impl Future<
Output = core::result::Result<
Response<Vec<u8>>,
Box<dyn std::error::Error + Send + Sync + 'static>,
>,
>;
#[cfg(not(target_arch = "wasm32"))]
fn send_http(
&self,
request: Request<Vec<u8>>,
) -> impl Future<Output = core::result::Result<Response<Vec<u8>>, Box<dyn std::error::Error + Send + Sync + 'static>>> + Send;
) -> impl Future<
Output = core::result::Result<
Response<Vec<u8>>,
Box<dyn std::error::Error + Send + Sync + 'static>,
>,
> + Send;
}

type XrpcResult<O, E> = core::result::Result<OutputDataOrBytes<O>, self::Error<E>>;
Expand All @@ -39,7 +49,10 @@ pub trait XrpcClient: HttpClient {
}
#[allow(unused_variables)]
#[cfg(not(target_arch = "wasm32"))]
fn authentication_token(&self, is_refresh: bool) -> impl Future<Output = Option<String>> + Send {
fn authentication_token(
&self,
is_refresh: bool,
) -> impl Future<Output = Option<String>> + Send {
async { None }
}
/// Get the `atproto-proxy` header.
Expand All @@ -62,7 +75,10 @@ pub trait XrpcClient: HttpClient {
}
/// Send an XRPC request and return the response.
#[cfg(target_arch = "wasm32")]
fn send_xrpc<P, I, O, E>(&self, request: &XrpcRequest<P, I>) -> impl Future<Output = XrpcResult<O, E>>
fn send_xrpc<P, I, O, E>(
&self,
request: &XrpcRequest<P, I>,
) -> impl Future<Output = XrpcResult<O, E>>
where
P: Serialize + Send + Sync,
I: Serialize + Send + Sync,
Expand All @@ -72,7 +88,10 @@ pub trait XrpcClient: HttpClient {
send_xrpc(self, request)
}
#[cfg(not(target_arch = "wasm32"))]
fn send_xrpc<P, I, O, E>(&self, request: &XrpcRequest<P, I>) -> impl Future<Output = XrpcResult<O, E>> + Send
fn send_xrpc<P, I, O, E>(
&self,
request: &XrpcRequest<P, I>,
) -> impl Future<Output = XrpcResult<O, E>> + Send
where
P: Serialize + Send + Sync,
I: Serialize + Send + Sync,
Expand All @@ -85,7 +104,10 @@ pub trait XrpcClient: HttpClient {
}

#[inline(always)]
async fn send_xrpc<P, I, O, E, C: XrpcClient + ?Sized>(client: &C, request: &XrpcRequest<P, I>) -> XrpcResult<O, E>
async fn send_xrpc<P, I, O, E, C: XrpcClient + ?Sized>(
client: &C,
request: &XrpcRequest<P, I>,
) -> XrpcResult<O, E>
where
P: Serialize + Send + Sync,
I: Serialize + Send + Sync,
Expand Down Expand Up @@ -148,4 +170,4 @@ where
error: serde_json::from_slice::<XrpcErrorKind<E>>(&body).ok(),
}))
}
}
}
8 changes: 6 additions & 2 deletions bsky-sdk/src/agent/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub trait Loader {
/// Loads the configuration data.
fn load(
&self,
) -> impl Future<Output = core::result::Result<Config, Box<dyn std::error::Error + Send + Sync + 'static>>> + Send;
) -> impl Future<
Output = core::result::Result<Config, Box<dyn std::error::Error + Send + Sync + 'static>>,
> + Send;
}

/// The trait for saving configuration data.
Expand All @@ -60,5 +62,7 @@ pub trait Saver {
fn save(
&self,
config: &Config,
) -> impl Future<Output = core::result::Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>> + Send;
) -> impl Future<
Output = core::result::Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>,
> + Send;
}
40 changes: 32 additions & 8 deletions bsky-sdk/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,45 @@ where
limit: Option<LimitedNonZeroU8<100u8>>,
) -> impl Future<Output = Result<list_records::Output>> + Send;
#[cfg(target_arch = "wasm32")]
fn get(agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<get_record::Output>>;
fn get(
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<get_record::Output>>;
#[cfg(not(target_arch = "wasm32"))]
fn get(agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<get_record::Output>> + Send;
fn get(
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<get_record::Output>> + Send;
#[cfg(target_arch = "wasm32")]
fn put(self, agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<put_record::Output>>;
fn put(
self,
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<put_record::Output>>;
#[cfg(not(target_arch = "wasm32"))]
fn put(self, agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<put_record::Output>> + Send;
fn put(
self,
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<put_record::Output>> + Send;
#[cfg(target_arch = "wasm32")]
fn create(self, agent: &BskyAgent<T, S>) -> impl Future<Output = Result<create_record::Output>>;
fn create(self, agent: &BskyAgent<T, S>)
-> impl Future<Output = Result<create_record::Output>>;
#[cfg(not(target_arch = "wasm32"))]
fn create(self, agent: &BskyAgent<T, S>) -> impl Future<Output = Result<create_record::Output>> + Send;
fn create(
self,
agent: &BskyAgent<T, S>,
) -> impl Future<Output = Result<create_record::Output>> + Send;
#[cfg(target_arch = "wasm32")]
fn delete(agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<delete_record::Output>>;
fn delete(
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<delete_record::Output>>;
#[cfg(not(target_arch = "wasm32"))]
fn delete(agent: &BskyAgent<T, S>, rkey: String) -> impl Future<Output = Result<delete_record::Output>> + Send;
fn delete(
agent: &BskyAgent<T, S>,
rkey: String,
) -> impl Future<Output = Result<delete_record::Output>> + Send;
}

macro_rules! record_impl {
Expand Down

0 comments on commit 4a9a4de

Please sign in to comment.