A better Rust ATProto crate

added setters for options and endpoint on XrpcClient both have default no-op implementations.

Orual ee0f31db 71aae4e8

Changed files
+44 -1
crates
jacquard
jacquard-common
src
jacquard-lexgen
jacquard-oauth
src
+12
crates/jacquard-common/src/xrpc.rs
··· 274 /// Get the base URI for the client. 275 fn base_uri(&self) -> impl Future<Output = Url>; 276 277 /// Get the call options for the client. 278 fn opts(&self) -> impl Future<Output = CallOptions<'_>> { 279 async { CallOptions::default() } 280 } 281 282 /// Send an XRPC request and parse the response
··· 274 /// Get the base URI for the client. 275 fn base_uri(&self) -> impl Future<Output = Url>; 276 277 + /// Set the base URI for the client. 278 + fn set_base_uri(&self, url: Url) -> impl Future<Output = ()> { 279 + let _ = url; 280 + async {} 281 + } 282 + 283 /// Get the call options for the client. 284 fn opts(&self) -> impl Future<Output = CallOptions<'_>> { 285 async { CallOptions::default() } 286 + } 287 + 288 + /// Set the call options for the client. 289 + fn set_opts(&self, opts: CallOptions) -> impl Future<Output = ()> { 290 + let _ = opts; 291 + async {} 292 } 293 294 /// Send an XRPC request and parse the response
-1
crates/jacquard-lexgen/Cargo.toml
··· 26 [[example]] 27 name = "extract_inventory" 28 path = "../../examples/extract_inventory.rs" 29 - required-features = ["codegen"] 30 31 32 [dependencies]
··· 26 [[example]] 27 name = "extract_inventory" 28 path = "../../examples/extract_inventory.rs" 29 30 31 [dependencies]
+10
crates/jacquard-oauth/src/client.rs
··· 466 self.options.read().await.clone() 467 } 468 469 async fn send<R>(&self, request: R) -> XrpcResult<XrpcResponse<R>> 470 where 471 R: XrpcRequest + Send + Sync,
··· 466 self.options.read().await.clone() 467 } 468 469 + async fn set_opts(&self, opts: CallOptions<'_>) { 470 + let mut guard = self.options.write().await; 471 + *guard = opts.into_static(); 472 + } 473 + 474 + async fn set_base_uri(&self, url: Url) { 475 + let mut guard = self.data.write().await; 476 + guard.host_url = url; 477 + } 478 + 479 async fn send<R>(&self, request: R) -> XrpcResult<XrpcResponse<R>> 480 where 481 R: XrpcRequest + Send + Sync,
+8
crates/jacquard/src/client.rs
··· 1020 fn opts(&self) -> impl Future<Output = CallOptions<'_>> { 1021 self.inner.opts() 1022 } 1023 fn send<R>( 1024 &self, 1025 request: R,
··· 1020 fn opts(&self) -> impl Future<Output = CallOptions<'_>> { 1021 self.inner.opts() 1022 } 1023 + 1024 + async fn set_opts(&self, opts: CallOptions<'_>) { 1025 + self.inner.set_opts(opts).await 1026 + } 1027 + 1028 + async fn set_base_uri(&self, url: url::Url) { 1029 + self.inner.set_base_uri(url).await 1030 + } 1031 fn send<R>( 1032 &self, 1033 request: R,
+14
crates/jacquard/src/client/credential_session.rs
··· 408 ) 409 } 410 411 async fn send<R>(&self, request: R) -> XrpcResult<XrpcResponse<R>> 412 where 413 R: XrpcRequest + Send + Sync,
··· 408 ) 409 } 410 411 + async fn opts(&self) -> CallOptions<'_> { 412 + self.options.read().await.clone() 413 + } 414 + 415 + async fn set_opts(&self, opts: CallOptions<'_>) { 416 + let mut guard = self.options.write().await; 417 + *guard = opts.into_static(); 418 + } 419 + 420 + async fn set_base_uri(&self, url: Url) { 421 + let mut guard = self.endpoint.write().await; 422 + *guard = Some(url); 423 + } 424 + 425 async fn send<R>(&self, request: R) -> XrpcResult<XrpcResponse<R>> 426 where 427 R: XrpcRequest + Send + Sync,