diff --git a/docs/src/rust_config.md b/docs/src/rust_config.md index 7c623a1cf..97d151333 100644 --- a/docs/src/rust_config.md +++ b/docs/src/rust_config.md @@ -117,7 +117,7 @@ Configure aioduct-specific dependency features for the generated crate. This sec ```toml [generators.rust-aioduct.aioduct] -version = "0.1.8" +version = "0.2" runtime = "tokio" tls = "rustls-ring" compression = ["gzip", "brotli", "zstd"] @@ -128,7 +128,7 @@ All fields are optional. Defaults: `runtime = "tokio"`, `tls = "rustls-ring"`, n #### `version` -Override the pinned aioduct version. Defaults to `"0.1.8"`. +Override the aioduct version requirement. Defaults to `"0.2"`. #### `runtime` diff --git a/src/generators/rust/aioduct/config.rs b/src/generators/rust/aioduct/config.rs index a298b42b0..1c76c7338 100644 --- a/src/generators/rust/aioduct/config.rs +++ b/src/generators/rust/aioduct/config.rs @@ -4,7 +4,7 @@ pub use crate::generators::rust::common::config::RustGeneratorConfig as RustAiod use serde::{Deserialize, Serialize}; -const DEFAULT_AIODUCT_VERSION: &str = "0.1.8"; +const DEFAULT_AIODUCT_VERSION: &str = "0.2"; #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "snake_case")] @@ -119,16 +119,16 @@ mod tests { #[test] fn default_version_is_current() { let config = AioductFeatureConfig::default(); - assert_eq!(config.version(), "0.1.8"); + assert_eq!(config.version(), "0.2"); } #[test] fn custom_version_override() { let config = AioductFeatureConfig { - version: Some("0.2.0".to_string()), + version: Some("0.2".to_string()), ..Default::default() }; - assert_eq!(config.version(), "0.2.0"); + assert_eq!(config.version(), "0.2"); } #[test] @@ -221,14 +221,14 @@ mod tests { #[test] fn deserialize_from_toml() { let toml_str = r#" - version = "0.2.0" + version = "0.2" runtime = "smol" tls = "rustls-aws-lc-rs" compression = ["gzip", "zstd"] features = ["tracing"] "#; let config: AioductFeatureConfig = toml::from_str(toml_str).unwrap(); - assert_eq!(config.version(), "0.2.0"); + assert_eq!(config.version(), "0.2"); assert_eq!(config.runtime, Some(AioductRuntime::Smol)); assert_eq!(config.tls, Some(AioductTls::RustlsAwsLcRs)); assert_eq!( diff --git a/src/generators/rust/aioduct/runtime.rs b/src/generators/rust/aioduct/runtime.rs index c51e3a32d..abcd35e92 100644 --- a/src/generators/rust/aioduct/runtime.rs +++ b/src/generators/rust/aioduct/runtime.rs @@ -48,12 +48,12 @@ fn render_client_rs(cfg: &AioductFeatureConfig) -> String { let constructor = match (tls, has_http3) { (AioductTls::RustlsRing | AioductTls::RustlsAwsLcRs, true) => { - "aioduct::Client::::with_http3()" + "aioduct::HttpEngineSend::::with_http3().expect(\"aioduct HTTP/3 client build\")" } (AioductTls::RustlsRing | AioductTls::RustlsAwsLcRs, false) => { - "aioduct::Client::::with_rustls()" + "aioduct::HttpEngineSend::::with_rustls()" } - (AioductTls::Disabled, _) => "aioduct::Client::::new()", + (AioductTls::Disabled, _) => "aioduct::HttpEngineSend::::new()", }; CLIENT_RS_TEMPLATE.replace("{{CLIENT_CONSTRUCTOR}}", constructor) diff --git a/src/generators/rust/aioduct/runtime/auth.rs.txt b/src/generators/rust/aioduct/runtime/auth.rs.txt index a4b7e2e47..dcabed33f 100644 --- a/src/generators/rust/aioduct/runtime/auth.rs.txt +++ b/src/generators/rust/aioduct/runtime/auth.rs.txt @@ -3,12 +3,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -74,11 +76,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -160,11 +162,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/src/generators/rust/aioduct/runtime/client.rs.txt b/src/generators/rust/aioduct/runtime/client.rs.txt index c0b6f2cf8..f1dfb0491 100644 --- a/src/generators/rust/aioduct/runtime/client.rs.txt +++ b/src/generators/rust/aioduct/runtime/client.rs.txt @@ -1,19 +1,17 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { @@ -22,9 +20,11 @@ impl Client { authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -33,7 +33,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -43,7 +43,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -52,7 +52,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -61,7 +61,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -70,7 +70,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -79,7 +79,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -88,7 +88,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -97,7 +97,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/src/generators/rust/aioduct/runtime/error.rs.txt b/src/generators/rust/aioduct/runtime/error.rs.txt index 81c7144fc..b2ad4143f 100644 --- a/src/generators/rust/aioduct/runtime/error.rs.txt +++ b/src/generators/rust/aioduct/runtime/error.rs.txt @@ -41,6 +41,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/src/generators/rust/aioduct/sigil_emit_api.rs b/src/generators/rust/aioduct/sigil_emit_api.rs index ac07884d0..cd2e86835 100644 --- a/src/generators/rust/aioduct/sigil_emit_api.rs +++ b/src/generators/rust/aioduct/sigil_emit_api.rs @@ -14,8 +14,8 @@ use crate::generators::rust::common::emit_api::{ pub fn aioduct_backend_config() -> RustBackendConfig { RustBackendConfig { is_async: true, - struct_generics: Some("R: aioduct::Runtime".to_string()), - client_type_args: Some("".to_string()), + struct_generics: Some("R: aioduct::RuntimePoll, C: aioduct::ConnectorSend".to_string()), + client_type_args: Some("".to_string()), } } diff --git a/src/generators/rust/common/emit_api.rs b/src/generators/rust/common/emit_api.rs index 84e9d5def..02b2eb33b 100644 --- a/src/generators/rust/common/emit_api.rs +++ b/src/generators/rust/common/emit_api.rs @@ -38,7 +38,7 @@ use super::emit_models::rust_type_str_qualified; pub struct RustBackendConfig { /// Whether methods are async (reqwest, aioduct) or sync (ureq). pub is_async: bool, - /// Extra generic parameters on the Api struct, e.g., `"R: aioduct::Runtime"`. + /// Extra generic parameters on the Api struct, e.g., `"R: aioduct::RuntimePoll"`. /// `None` for reqwest and ureq. pub struct_generics: Option, /// Extra generic args for the client field type, e.g., `""`. @@ -135,15 +135,19 @@ fn emit_api_file( fsb = fsb.add_import(ImportSpec::named("crate::runtime::client", "Client")); fsb = fsb.add_import(ImportSpec::named("crate::runtime::error", "Error")); - // Struct generics (e.g., `<'a, R: aioduct::Runtime>`) + // Struct generics (e.g., `<'a, R: aioduct::RuntimePoll>`) let (struct_gen, impl_gen, type_args, client_field_args) = match &config.struct_generics { Some(g) => { let client_args = config.client_type_args.as_deref().unwrap_or(""); - let param_name = g.split(':').next().unwrap_or(g).trim(); + let param_names = g + .split(',') + .map(|param| param.split(':').next().unwrap_or(param).trim()) + .collect::>() + .join(", "); ( format!("<'a, {g}>"), format!("<'a, {g}>"), - format!("<'a, {param_name}>"), + format!("<'a, {param_names}>"), client_args.to_string(), ) } diff --git a/tests/golden/rust/rust-aioduct/additional-properties/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/additional-properties/Cargo.toml.golden index d1d6d03db..b940f27ec 100644 --- a/tests/golden/rust/rust-aioduct/additional-properties/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/additional-properties/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "API demonstrating OpenAPI additionalProperties with multiple levels of structs (RootLevel -> MiddleLevel -> LeafValue), each with HashMap fields." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/additional-properties/src/apis/additional_properties.rs.golden b/tests/golden/rust/rust-aioduct/additional-properties/src/apis/additional_properties.rs.golden index 8a77ce794..55a0610e0 100644 --- a/tests/golden/rust/rust-aioduct/additional-properties/src/apis/additional_properties.rs.golden +++ b/tests/golden/rust/rust-aioduct/additional-properties/src/apis/additional_properties.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "additional-properties" tag. -pub struct AdditionalPropertiesApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct AdditionalPropertiesApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> AdditionalPropertiesApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> AdditionalPropertiesApi<'a, R, C> { /// Create a new `AdditionalPropertiesApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/auth.rs.golden index 6842f9ecc..601bf88d1 100644 --- a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/client.rs.golden index 3d6de37e0..15cb79360 100644 --- a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/error.rs.golden index 0e0f5d9a6..2d8fa644f 100644 --- a/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/additional-properties/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/Cargo.toml.golden index 6c5fe3163..890ffbe6d 100644 --- a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers multipart upload and octet-stream download." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/apis/transfer.rs.golden b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/apis/transfer.rs.golden index 38c937eb7..b21afcb2d 100644 --- a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/apis/transfer.rs.golden +++ b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/apis/transfer.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "transfer" tag. -pub struct TransferApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct TransferApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> TransferApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> TransferApi<'a, R, C> { /// Create a new `TransferApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/auth.rs.golden index e91d63afa..8ac7f8a88 100644 --- a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/client.rs.golden index f703f7607..cb8e27423 100644 --- a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/error.rs.golden index b87588bec..b1253b786 100644 --- a/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/binary-transfer-media-types/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/comprehensive-schemas/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/comprehensive-schemas/Cargo.toml.golden index fd2709958..1d3de4449 100644 --- a/tests/golden/rust/rust-aioduct/comprehensive-schemas/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/comprehensive-schemas/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Comprehensive test for all OpenAPI v3.1.2 schema types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/apis/default.rs.golden index 9ba288fc1..c111d9349 100644 --- a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/auth.rs.golden index 03590d5f8..2f8685996 100644 --- a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/client.rs.golden index 28f690e59..7cfa5a4bf 100644 --- a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/error.rs.golden index 0f3632933..644b0f446 100644 --- a/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/comprehensive-schemas/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/delete-with-response-schema/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/delete-with-response-schema/Cargo.toml.golden index cdc945c91..b054891aa 100644 --- a/tests/golden/rust/rust-aioduct/delete-with-response-schema/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/delete-with-response-schema/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for DELETE operations with JSON response schemas and type alias request bodies" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/apis/test_resource.rs.golden b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/apis/test_resource.rs.golden index c545cda93..bb2a8e0a8 100644 --- a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/apis/test_resource.rs.golden +++ b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/apis/test_resource.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "test-resource" tag. -pub struct TestResourceApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct TestResourceApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> TestResourceApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> TestResourceApi<'a, R, C> { /// Create a new `TestResourceApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/auth.rs.golden index abc08a1aa..488d3d6db 100644 --- a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/client.rs.golden index 68d89f467..a3fc50174 100644 --- a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/error.rs.golden index a1fcb9838..072f4d65d 100644 --- a/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/delete-with-response-schema/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/Cargo.toml.golden index df768fa42..714986422 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test API with duplicate parameter names across different locations" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/items.rs.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/items.rs.golden index 177e16db8..80e433899 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/items.rs.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/items.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "items" tag. -pub struct ItemsApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct ItemsApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> ItemsApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> ItemsApi<'a, R, C> { /// Create a new `ItemsApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/users.rs.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/users.rs.golden index ee7d39cf3..49838cae6 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/users.rs.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/apis/users.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "users" tag. -pub struct UsersApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct UsersApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> UsersApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> UsersApi<'a, R, C> { /// Create a new `UsersApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/auth.rs.golden index 914245405..99bb69358 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/client.rs.golden index ebc4095af..3b8591dd1 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/error.rs.golden index 4539a1f78..b7dadba6b 100644 --- a/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/duplicate-param-names/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/enum-repr/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/enum-repr/Cargo.toml.golden index c5c18d97c..75ae8f5c8 100644 --- a/tests/golden/rust/rust-aioduct/enum-repr/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/enum-repr/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "This API demonstrates all 4 kinds of enum representation types: Externally Tagged, Internally Tagged, Adjacently Tagged, and Untagged" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/enum-repr/src/apis/enum_repr.rs.golden b/tests/golden/rust/rust-aioduct/enum-repr/src/apis/enum_repr.rs.golden index 14a219640..4edf90f34 100644 --- a/tests/golden/rust/rust-aioduct/enum-repr/src/apis/enum_repr.rs.golden +++ b/tests/golden/rust/rust-aioduct/enum-repr/src/apis/enum_repr.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "enum-repr" tag. -pub struct EnumReprApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct EnumReprApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> EnumReprApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> EnumReprApi<'a, R, C> { /// Create a new `EnumReprApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/auth.rs.golden index edc15bb91..50b69c707 100644 --- a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/client.rs.golden index 7e3aff601..de18a146b 100644 --- a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/error.rs.golden index c6584a339..62c773014 100644 --- a/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/enum-repr/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/Cargo.toml.golden index 55e11a8d0..2bb57a5aa 100644 --- a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for interfaces that reference enum types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/auth.rs.golden index bc8459b3b..c5e17e7ea 100644 --- a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/client.rs.golden index 296a32eb0..341d894b4 100644 --- a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/error.rs.golden index 1d9ecca76..45d86cc39 100644 --- a/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/interface-with-enum-reference/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/media-type-selection/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/media-type-selection/Cargo.toml.golden index 4efda2c34..aa47e15c5 100644 --- a/tests/golden/rust/rust-aioduct/media-type-selection/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/media-type-selection/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers normalized media-type selection for requests and responses." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/media-type-selection/src/apis/media.rs.golden b/tests/golden/rust/rust-aioduct/media-type-selection/src/apis/media.rs.golden index 7be5f0eca..2b6c8a9e5 100644 --- a/tests/golden/rust/rust-aioduct/media-type-selection/src/apis/media.rs.golden +++ b/tests/golden/rust/rust-aioduct/media-type-selection/src/apis/media.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "media" tag. -pub struct MediaApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct MediaApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> MediaApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> MediaApi<'a, R, C> { /// Create a new `MediaApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/auth.rs.golden index 8988c4a44..637a071d4 100644 --- a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/client.rs.golden index f115d5af0..0a4c59516 100644 --- a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/error.rs.golden index 141130bde..2e38a5e62 100644 --- a/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/media-type-selection/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/minimal/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/minimal/Cargo.toml.golden index c65b85fd4..f6431b5ae 100644 --- a/tests/golden/rust/rust-aioduct/minimal/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/minimal/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Generated Rust SDK." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/minimal/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/minimal/src/apis/default.rs.golden index 0d9b6b5cd..f7af9dad2 100644 --- a/tests/golden/rust/rust-aioduct/minimal/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/minimal/src/apis/default.rs.golden @@ -7,13 +7,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/minimal/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/minimal/src/runtime/auth.rs.golden index d55ce7d66..c018dd27d 100644 --- a/tests/golden/rust/rust-aioduct/minimal/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/minimal/src/runtime/auth.rs.golden @@ -8,12 +8,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -79,11 +81,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -165,11 +167,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/minimal/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/minimal/src/runtime/client.rs.golden index 6d8deb132..d764d534e 100644 --- a/tests/golden/rust/rust-aioduct/minimal/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/minimal/src/runtime/client.rs.golden @@ -6,30 +6,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -38,7 +38,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -48,7 +48,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -57,7 +57,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -66,7 +66,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -75,7 +75,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -84,7 +84,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -93,7 +93,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -102,7 +102,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/minimal/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/minimal/src/runtime/error.rs.golden index 3156963d9..c981d9517 100644 --- a/tests/golden/rust/rust-aioduct/minimal/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/minimal/src/runtime/error.rs.golden @@ -46,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/Cargo.toml.golden index d699f8c71..2d4bec43e 100644 --- a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "A test fixture for multi-line doc comments" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/apis/default.rs.golden index 4a5c1dd00..d5b7a2425 100644 --- a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/apis/default.rs.golden @@ -9,13 +9,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/auth.rs.golden index 1c665a3ee..3333deef2 100644 --- a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/auth.rs.golden @@ -10,12 +10,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -81,11 +83,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -167,11 +169,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/client.rs.golden index 8db5c8b62..f07eb601c 100644 --- a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/client.rs.golden @@ -8,30 +8,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -40,7 +40,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -50,7 +50,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -59,7 +59,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -68,7 +68,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -77,7 +77,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -86,7 +86,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -95,7 +95,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -104,7 +104,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/error.rs.golden index e12f888bb..e036a1b11 100644 --- a/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiline-docs-and-primitive-alias/src/runtime/error.rs.golden @@ -48,6 +48,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multipart-edge-cases/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multipart-edge-cases/Cargo.toml.golden index 812e2a02a..4755a0142 100644 --- a/tests/golden/rust/rust-aioduct/multipart-edge-cases/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multipart-edge-cases/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers optional multipart bodies, optional parts, and text-only multipart fields." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/apis/multipart.rs.golden b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/apis/multipart.rs.golden index bfeb4e8a1..bb5c6a451 100644 --- a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/apis/multipart.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/apis/multipart.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "multipart" tag. -pub struct MultipartApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct MultipartApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> MultipartApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> MultipartApi<'a, R, C> { /// Create a new `MultipartApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/auth.rs.golden index 44ec63dae..e770bcaf7 100644 --- a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/client.rs.golden index 6bd5255ea..22cb364e4 100644 --- a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/error.rs.golden index 4a0a4327f..7135a26c7 100644 --- a/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-edge-cases/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/Cargo.toml.golden index e5cd3541b..f8c01bcaa 100644 --- a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers explicit multipart part content types." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/apis/transfer.rs.golden b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/apis/transfer.rs.golden index a579174e9..8e731b93d 100644 --- a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/apis/transfer.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/apis/transfer.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "transfer" tag. -pub struct TransferApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct TransferApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> TransferApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> TransferApi<'a, R, C> { /// Create a new `TransferApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/auth.rs.golden index 7b84d0270..2e2b4c864 100644 --- a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/client.rs.golden index dfdf2fad9..593a72e1c 100644 --- a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/error.rs.golden index 1bf06330b..e6076bb16 100644 --- a/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-explicit-encoding/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/Cargo.toml.golden index 6c497981b..49d5668f1 100644 --- a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers multipart object parts whose wire names differ from ergonomic names." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/apis/multipart.rs.golden b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/apis/multipart.rs.golden index 1f20ce4e5..077db54ed 100644 --- a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/apis/multipart.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/apis/multipart.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "multipart" tag. -pub struct MultipartApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct MultipartApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> MultipartApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> MultipartApi<'a, R, C> { /// Create a new `MultipartApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/auth.rs.golden index 300a9b444..c6d943dd7 100644 --- a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/client.rs.golden index 24ff5605e..e442a62ae 100644 --- a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/error.rs.golden index f82d173f9..afd358107 100644 --- a/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-nested-object-parts/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/Cargo.toml.golden index 20f056f66..5e2b51fd1 100644 --- a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers multipart request bodies that are not object-shaped." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/apis/transfer.rs.golden b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/apis/transfer.rs.golden index d6d0f72fc..093938e37 100644 --- a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/apis/transfer.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/apis/transfer.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "transfer" tag. -pub struct TransferApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct TransferApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> TransferApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> TransferApi<'a, R, C> { /// Create a new `TransferApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/auth.rs.golden index 9a0c7593d..e49500a9e 100644 --- a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/client.rs.golden index cc434952f..0f444f746 100644 --- a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/error.rs.golden index c917811c0..b87bfceff 100644 --- a/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multipart-unsupported-schema/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/Cargo.toml.golden index 9eb17e567..5f53f6f8c 100644 --- a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test API with multiple operations having similar request body schema names" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/apis/test_api.rs.golden b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/apis/test_api.rs.golden index f2b270bee..8a3828f3f 100644 --- a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/apis/test_api.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/apis/test_api.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "test-api" tag. -pub struct TestApiApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct TestApiApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> TestApiApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> TestApiApi<'a, R, C> { /// Create a new `TestApiApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/auth.rs.golden index 0e20c2d40..9dc7c2059 100644 --- a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/client.rs.golden index df3ffa3a0..f60c13711 100644 --- a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/error.rs.golden index 1048a7412..8aedd860f 100644 --- a/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/multiple-similar-request-schemas/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/naming-conventions/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/naming-conventions/Cargo.toml.golden index 39b6cdc20..479abe533 100644 --- a/tests/golden/rust/rust-aioduct/naming-conventions/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/naming-conventions/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture to verify language property naming conventions" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/naming-conventions/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/naming-conventions/src/apis/default.rs.golden index 3bf696064..4cdd3f38c 100644 --- a/tests/golden/rust/rust-aioduct/naming-conventions/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/naming-conventions/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/auth.rs.golden index 8b567c9ba..390ae82cd 100644 --- a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/client.rs.golden index 019be03fd..1c2504367 100644 --- a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/error.rs.golden index 7511d1232..708c7ed36 100644 --- a/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/naming-conventions/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/optional-request-bodies/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/optional-request-bodies/Cargo.toml.golden index b034d03d9..7e6a4d420 100644 --- a/tests/golden/rust/rust-aioduct/optional-request-bodies/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/optional-request-bodies/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers optional non-multipart request bodies." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/apis/default.rs.golden index 23ccea225..839070978 100644 --- a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/auth.rs.golden index 976a4d8d0..6eafe0f0b 100644 --- a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/client.rs.golden index aa8c6353a..ba236bc3f 100644 --- a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/error.rs.golden index 4e56f2aa9..c54a54f6f 100644 --- a/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/optional-request-bodies/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/petstore/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/petstore/Cargo.toml.golden index 1374da520..62578bac1 100644 --- a/tests/golden/rust/rust-aioduct/petstore/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/petstore/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "This is a sample Pet Store Server based on the OpenAPI 3.1 specification" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/petstore/src/apis/pet.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/apis/pet.rs.golden index 7f1677b7d..b1ad2d5ad 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/apis/pet.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/apis/pet.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "pet" tag. -pub struct PetApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct PetApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> PetApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> PetApi<'a, R, C> { /// Create a new `PetApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/petstore/src/apis/store.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/apis/store.rs.golden index d71ae4c67..fbe6e29cc 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/apis/store.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/apis/store.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "store" tag. -pub struct StoreApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct StoreApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> StoreApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> StoreApi<'a, R, C> { /// Create a new `StoreApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/petstore/src/apis/user.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/apis/user.rs.golden index bfdbf50e4..e7e123b9b 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/apis/user.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/apis/user.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "user" tag. -pub struct UserApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct UserApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> UserApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> UserApi<'a, R, C> { /// Create a new `UserApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/petstore/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/runtime/auth.rs.golden index 7865b588e..549fd42f6 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/petstore/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/runtime/client.rs.golden index 81e80d764..25db02585 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/petstore/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/petstore/src/runtime/error.rs.golden index 8680032e3..acbe3ab4a 100644 --- a/tests/golden/rust/rust-aioduct/petstore/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/petstore/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/query-param-enum/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/query-param-enum/Cargo.toml.golden index e7b8a4dc6..22f1f3486 100644 --- a/tests/golden/rust/rust-aioduct/query-param-enum/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/query-param-enum/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for query parameters that reference enum schemas" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/query-param-enum/src/apis/items.rs.golden b/tests/golden/rust/rust-aioduct/query-param-enum/src/apis/items.rs.golden index c43dfeec2..6fb649ec5 100644 --- a/tests/golden/rust/rust-aioduct/query-param-enum/src/apis/items.rs.golden +++ b/tests/golden/rust/rust-aioduct/query-param-enum/src/apis/items.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "items" tag. -pub struct ItemsApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct ItemsApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> ItemsApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> ItemsApi<'a, R, C> { /// Create a new `ItemsApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/auth.rs.golden index 41f74573d..e9d678681 100644 --- a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/client.rs.golden index 97c3cd4e6..bf281d4d6 100644 --- a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/error.rs.golden index 9ecc8b2ec..619413f38 100644 --- a/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/query-param-enum/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/Cargo.toml.golden index 9a19ab45f..75dee4672 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for object with all optional properties including arrays, references, and inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/apis/default.rs.golden index 759450ecd..43e15ce46 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/auth.rs.golden index 80d813299..e48965f5c 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/client.rs.golden index 2709f533e..7c3eaf103 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/error.rs.golden index d2527b1d4..f1f3d3e95 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-all-optional-properties/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/Cargo.toml.golden index 75c5e85cc..c76dab246 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for array of inline objects with snake_case to camelCase conversion (main case from user issue)" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/apis/default.rs.golden index b653783b0..36b2e699e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/auth.rs.golden index ad149f6c0..4823a2a7e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/client.rs.golden index 592cfadaa..46cbd51fe 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/error.rs.golden index b86730a44..936feada3 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-inline-objects/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/Cargo.toml.golden index 768ec62ce..0f7bc0ee2 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for array of referenced model types with recursive FromJSON calls" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/apis/default.rs.golden index 4f4f0dbec..cee12aafd 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/auth.rs.golden index 337d655e2..fe6f6c4ab 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/client.rs.golden index e1742d824..a168ed81a 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/error.rs.golden index e7c0b7b92..72cc9469e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-of-referenced-types/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/Cargo.toml.golden index ad442d8c2..a719e5d26 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for array of inline objects that contain a reference property" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/apis/default.rs.golden index 30b4ebef1..ea627b942 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/auth.rs.golden index bbfc9ea43..d0702b3ef 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/client.rs.golden index 937486c8e..e55050279 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/error.rs.golden index 2d83adb03..ed4b04398 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-array-with-reference-property/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/Cargo.toml.golden index 7663a02aa..6b7bf8729 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for array of inline objects where each object has nested inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/apis/default.rs.golden index 6c3c488a4..6dfecb209 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/auth.rs.golden index 3bd2658ed..9ea9f4529 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/client.rs.golden index b92c2d8cb..b6871399b 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/error.rs.golden index 83d1827aa..b203b3423 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-complex-array-structure/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/Cargo.toml.golden index 7c99ab61d..67ce0dc6e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for three levels of nested inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/apis/default.rs.golden index 2d5b175b4..499f35827 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/auth.rs.golden index 9ec262bd6..4128a3065 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/client.rs.golden index 94cd0837b..bc0cc47fc 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/error.rs.golden index 4e20c979c..3b7d3d4ec 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-deeply-nested-inline/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/Cargo.toml.golden index a2ee3073b..b3af6d055 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for empty array handling" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/apis/default.rs.golden index b3cf912b5..fde0edd8d 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/auth.rs.golden index 27a18d897..df5d0f916 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/client.rs.golden index 4ea907691..9c3a2ba98 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/error.rs.golden index 88905f53c..4c0e48295 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-empty-array/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/Cargo.toml.golden index 492c0a429..d417f7340 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for inline object containing an array of inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/apis/default.rs.golden index fb82bf34d..1d063514f 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/auth.rs.golden index 28c7de650..4ef2102bf 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/client.rs.golden index 41904f574..994608ab9 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/error.rs.golden index 15027e815..3f4e280da 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object-with-array/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/Cargo.toml.golden index fa486a1ba..860ad4411 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for inline objects (not arrays) with snake_case to camelCase conversion" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/apis/default.rs.golden index cc2b4841a..d83dba5c1 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/auth.rs.golden index 9c9425378..9c661f10f 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/client.rs.golden index 53c80611d..f276356b0 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/error.rs.golden index f775d7078..8eee9c968 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-inline-object/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/Cargo.toml.golden index ebed3d991..c75371401 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for object with mix of simple types, arrays, references, and inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/apis/default.rs.golden index 33f612eb6..4994b2de5 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/auth.rs.golden index 5461ac3f3..5d73ee3d2 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/client.rs.golden index 602d3a007..837a83619 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/error.rs.golden index 4700f37d5..cc75a9387 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-mixed-property-types/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/Cargo.toml.golden index be35e5c63..a2c9816fe 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for nested object reference with recursive FromJSON calls" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/apis/default.rs.golden index 1f89d3751..08cf52c99 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/auth.rs.golden index 8d1432ce7..ede488ef0 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/client.rs.golden index 31c3e34d7..ad34fd0de 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/error.rs.golden index 7b5de561f..6a0431597 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-nested-object-reference/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/Cargo.toml.golden index 4ab0f521d..b83290e7e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for optional array of inline objects with snake_case to camelCase conversion" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/apis/default.rs.golden index 4687303ea..c320d2188 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/auth.rs.golden index 08f040f73..008c72227 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/client.rs.golden index 7a376a9df..89dcdf937 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/error.rs.golden index b9681e10d..92c04b20f 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-inline-objects/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/Cargo.toml.golden index ec66fdf2a..0c5063cf1 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for optional array of referenced model types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/apis/default.rs.golden index d3cce57fb..c7799bce4 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/auth.rs.golden index e25026c5d..196264b8a 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/client.rs.golden index 9ab1174b6..f541b0b7f 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/error.rs.golden index 6a121ab58..107498f84 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-array-of-referenced-types/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/Cargo.toml.golden index 579d3af44..7b9a9f4e6 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for optional inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/apis/default.rs.golden index 7b11d5c5c..494b48178 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/auth.rs.golden index d697f1ca9..548d333d1 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/client.rs.golden index 2e521686c..e2875aa8e 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/error.rs.golden index 92666f9cd..3c3f052f1 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-inline-object/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/Cargo.toml.golden index 837032784..8e78c0c28 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for optional nested object reference" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/apis/default.rs.golden index 1311695b9..cda3fc4f7 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/auth.rs.golden index d94dd61a9..ae521f383 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/client.rs.golden index b28e1f3dc..36e7f60b1 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/error.rs.golden index b7162fc77..bc9f7f117 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-optional-nested-object-reference/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/Cargo.toml.golden index 2243a3915..428389b56 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test case for arrays with primitive items (should not be affected by recursive parsing)" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/apis/default.rs.golden index a4eda817a..57c08c999 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/auth.rs.golden index d5444ef4e..a5d1dfc69 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/client.rs.golden index d9aafd214..b7f60a7a3 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/error.rs.golden index ccaa0e0b1..de7cb646c 100644 --- a/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/recursive-json-primitive-array/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/request-body-content-types/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/request-body-content-types/Cargo.toml.golden index fc84af8c2..21e004aa6 100644 --- a/tests/golden/rust/rust-aioduct/request-body-content-types/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/request-body-content-types/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Covers non-JSON request body media types to pin Content-Type emission." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/request-body-content-types/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/request-body-content-types/src/apis/default.rs.golden index 9769ac4b5..9e8946f56 100644 --- a/tests/golden/rust/rust-aioduct/request-body-content-types/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/request-body-content-types/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/auth.rs.golden index b5e8e3a8a..107cbc962 100644 --- a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/client.rs.golden index b5db5a06b..712820a1a 100644 --- a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/error.rs.golden index dfa8eb50f..7d76eb3cb 100644 --- a/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/request-body-content-types/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/Cargo.toml.golden index 007960af1..5605a43a4 100644 --- a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Generated Rust SDK." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/apis/widget.rs.golden b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/apis/widget.rs.golden index a19a1d6ac..7b44e244b 100644 --- a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/apis/widget.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/apis/widget.rs.golden @@ -7,13 +7,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "Widget" tag. -pub struct WidgetApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct WidgetApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> WidgetApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> WidgetApi<'a, R, C> { /// Create a new `WidgetApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/auth.rs.golden index fbef1ee96..e3b1e1e2b 100644 --- a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/auth.rs.golden @@ -8,12 +8,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -79,11 +81,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -165,11 +167,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/client.rs.golden index 6e303c468..659ee4d80 100644 --- a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/client.rs.golden @@ -6,30 +6,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -38,7 +38,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -48,7 +48,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -57,7 +57,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -66,7 +66,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -75,7 +75,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -84,7 +84,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -93,7 +93,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -102,7 +102,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/error.rs.golden index b1f1edd66..2fb8cc4a5 100644 --- a/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-default-and-exact/src/runtime/error.rs.golden @@ -46,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/response-body-fallback/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/response-body-fallback/Cargo.toml.golden index e29eddb26..c0640365e 100644 --- a/tests/golden/rust/rust-aioduct/response-body-fallback/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/response-body-fallback/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Generated Rust SDK." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/response-body-fallback/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/response-body-fallback/src/apis/default.rs.golden index 8bf7f2a6b..2224da3a4 100644 --- a/tests/golden/rust/rust-aioduct/response-body-fallback/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-fallback/src/apis/default.rs.golden @@ -7,13 +7,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/auth.rs.golden index a799b7109..a6b59b867 100644 --- a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/auth.rs.golden @@ -8,12 +8,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -79,11 +81,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -165,11 +167,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/client.rs.golden index 7c034480f..5d72ed90e 100644 --- a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/client.rs.golden @@ -6,30 +6,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -38,7 +38,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -48,7 +48,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -57,7 +57,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -66,7 +66,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -75,7 +75,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -84,7 +84,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -93,7 +93,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -102,7 +102,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/error.rs.golden index 1f5230a0c..cdb4b4ef1 100644 --- a/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-fallback/src/runtime/error.rs.golden @@ -46,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/Cargo.toml.golden index c2ff503b4..3dfd2cb32 100644 --- a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Generated Rust SDK." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/apis/widget.rs.golden b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/apis/widget.rs.golden index 79918e776..caca110ca 100644 --- a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/apis/widget.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/apis/widget.rs.golden @@ -7,13 +7,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "Widget" tag. -pub struct WidgetApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct WidgetApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> WidgetApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> WidgetApi<'a, R, C> { /// Create a new `WidgetApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/auth.rs.golden index c1dc22211..381489625 100644 --- a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/auth.rs.golden @@ -8,12 +8,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -79,11 +81,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -165,11 +167,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/client.rs.golden index 8679335d0..db0a7678e 100644 --- a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/client.rs.golden @@ -6,30 +6,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -38,7 +38,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -48,7 +48,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -57,7 +57,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -66,7 +66,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -75,7 +75,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -84,7 +84,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -93,7 +93,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -102,7 +102,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/error.rs.golden index 34ad5009c..fbd5fe2f3 100644 --- a/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-multi-status-responses/src/runtime/error.rs.golden @@ -46,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/response-body-no-response-body/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/response-body-no-response-body/Cargo.toml.golden index 3b89ef859..bb5b35467 100644 --- a/tests/golden/rust/rust-aioduct/response-body-no-response-body/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/response-body-no-response-body/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Generated Rust SDK." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/apis/foo.rs.golden b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/apis/foo.rs.golden index 7b3080f51..d95f9556f 100644 --- a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/apis/foo.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/apis/foo.rs.golden @@ -7,13 +7,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "Foo" tag. -pub struct FooApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct FooApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> FooApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> FooApi<'a, R, C> { /// Create a new `FooApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/auth.rs.golden index 6028bab29..914a3d508 100644 --- a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/auth.rs.golden @@ -8,12 +8,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -79,11 +81,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -165,11 +167,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/client.rs.golden index cd2ea613f..a26e8dbd7 100644 --- a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/client.rs.golden @@ -6,30 +6,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -38,7 +38,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -48,7 +48,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -57,7 +57,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -66,7 +66,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -75,7 +75,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -84,7 +84,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -93,7 +93,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -102,7 +102,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/error.rs.golden index 7d99790f5..e798eda9e 100644 --- a/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/response-body-no-response-body/src/runtime/error.rs.golden @@ -46,6 +46,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/server-object/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/server-object/Cargo.toml.golden index cecf2526a..54f4dbd74 100644 --- a/tests/golden/rust/rust-aioduct/server-object/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/server-object/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "This is a test API specification that includes various server configurations" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/server-object/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/server-object/src/apis/default.rs.golden index a908fb038..7152b1625 100644 --- a/tests/golden/rust/rust-aioduct/server-object/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-object/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/server-object/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/server-object/src/runtime/auth.rs.golden index 2a99cff2f..023afab2c 100644 --- a/tests/golden/rust/rust-aioduct/server-object/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-object/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/server-object/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/server-object/src/runtime/client.rs.golden index aa44e9e3f..3390451aa 100644 --- a/tests/golden/rust/rust-aioduct/server-object/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-object/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/server-object/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/server-object/src/runtime/error.rs.golden index d5154cea9..abc6c8f83 100644 --- a/tests/golden/rust/rust-aioduct/server-object/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-object/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/server-path-prefix/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/server-path-prefix/Cargo.toml.golden index 0779ece54..fe0019051 100644 --- a/tests/golden/rust/rust-aioduct/server-path-prefix/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/server-path-prefix/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for server URL path prefix stripping in operation paths." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/server-path-prefix/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/server-path-prefix/src/apis/default.rs.golden index 713207b9a..262eda247 100644 --- a/tests/golden/rust/rust-aioduct/server-path-prefix/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-path-prefix/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/auth.rs.golden index 77e1c0b76..ad7d56fba 100644 --- a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/client.rs.golden index 09d762880..2bb2f123b 100644 --- a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/error.rs.golden index 88a2f220a..d5ce8719b 100644 --- a/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/server-path-prefix/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/Cargo.toml.golden index 7675844cc..5e7d80c20 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for complex union types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/apis/default.rs.golden index 4f954a98c..f40be42ea 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/auth.rs.golden index 024a9050f..ed21fbb6a 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/client.rs.golden index 01ca6c1f3..0d9d42572 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/error.rs.golden index 4310b5fd7..f08817a12 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-complex-union/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/Cargo.toml.golden index 3fcca09f5..e72839546 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for discriminated union where variants are inline objects" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/apis/default.rs.golden index 11b655b38..51165d054 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/apis/default.rs.golden @@ -17,13 +17,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/auth.rs.golden index b0c8ef656..a6718f1c4 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/auth.rs.golden @@ -18,12 +18,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -89,11 +91,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -175,11 +177,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/client.rs.golden index 4a5d5cb8a..5a9d14755 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/client.rs.golden @@ -16,30 +16,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -48,7 +48,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -58,7 +58,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -112,7 +112,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/error.rs.golden index 59aa6e599..5a9c45f3e 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-inline-discriminator-only/src/runtime/error.rs.golden @@ -56,6 +56,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/Cargo.toml.golden index f97f3f1f6..d338a12f9 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for internally tagged (adjacently tagged) discriminator unions." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/apis/default.rs.golden index 85353a10d..c041e8c13 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/apis/default.rs.golden @@ -10,13 +10,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/auth.rs.golden index 7f8361f03..2814f3ce6 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/auth.rs.golden @@ -11,12 +11,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -82,11 +84,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -168,11 +170,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/client.rs.golden index bc562d5bb..177b7723c 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/client.rs.golden @@ -9,30 +9,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -41,7 +41,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -51,7 +51,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -60,7 +60,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -69,7 +69,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -78,7 +78,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -87,7 +87,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -96,7 +96,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -105,7 +105,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/error.rs.golden index 01e1952a3..88555edc7 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-internally-tagged/src/runtime/error.rs.golden @@ -49,6 +49,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/Cargo.toml.golden index 13c50f4d0..dec949c39 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for discriminated union where variant type names are" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/apis/default.rs.golden index e9136367d..667c833d3 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/apis/default.rs.golden @@ -10,13 +10,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/auth.rs.golden index 96bbff4dd..d61ea0617 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/auth.rs.golden @@ -11,12 +11,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -82,11 +84,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -168,11 +170,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/client.rs.golden index f58f57383..3e9d57f94 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/client.rs.golden @@ -9,30 +9,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -41,7 +41,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -51,7 +51,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -60,7 +60,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -69,7 +69,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -78,7 +78,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -87,7 +87,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -96,7 +96,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -105,7 +105,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/error.rs.golden index 9dda54368..1d7808de3 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-long-names/src/runtime/error.rs.golden @@ -49,6 +49,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/Cargo.toml.golden index 67d0d203d..6f7683c34 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for internally tagged discriminated union where the \"unspecified\"" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/apis/default.rs.golden index 834c99c4e..9011ecaf0 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/apis/default.rs.golden @@ -13,13 +13,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/auth.rs.golden index c7a9eb1a4..adab51a0e 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/auth.rs.golden @@ -14,12 +14,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -85,11 +87,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -171,11 +173,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/client.rs.golden index b687033f2..d644571cd 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/client.rs.golden @@ -12,30 +12,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -44,7 +44,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -54,7 +54,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -63,7 +63,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -72,7 +72,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -81,7 +81,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -90,7 +90,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -99,7 +99,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -108,7 +108,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/error.rs.golden index f00d62b43..88a0dc3fe 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-mixed-unit-and-allof/src/runtime/error.rs.golden @@ -52,6 +52,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/Cargo.toml.golden index 1a97e46d6..69993846d 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture with multiple discriminated unions to verify Kind types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/apis/default.rs.golden index fc5daeb89..14ff2cb9d 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/apis/default.rs.golden @@ -11,13 +11,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/auth.rs.golden index b5b8c9107..ee31efb19 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/auth.rs.golden @@ -12,12 +12,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -83,11 +85,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -169,11 +171,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/client.rs.golden index 07170db1d..88d57f494 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/client.rs.golden @@ -10,30 +10,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -42,7 +42,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -52,7 +52,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -61,7 +61,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -70,7 +70,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -79,7 +79,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -88,7 +88,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -97,7 +97,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -106,7 +106,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/error.rs.golden index 4307a213e..41ec01070 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-multiple/src/runtime/error.rs.golden @@ -50,6 +50,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/Cargo.toml.golden index e77ac46a0..72e186dee 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for discriminated union where variants are references to component schemas." [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/apis/default.rs.golden index 6afbe901e..af0da3256 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/apis/default.rs.golden @@ -9,13 +9,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/auth.rs.golden index 33e58fbbd..7869d3ccd 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/auth.rs.golden @@ -10,12 +10,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -81,11 +83,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -167,11 +169,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/client.rs.golden index 1e5173c80..772a6bf32 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/client.rs.golden @@ -8,30 +8,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -40,7 +40,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -50,7 +50,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -59,7 +59,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -68,7 +68,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -77,7 +77,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -86,7 +86,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -95,7 +95,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -104,7 +104,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/error.rs.golden index a5437cab5..61976b276 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-discriminated-union-with-refs/src/runtime/error.rs.golden @@ -48,6 +48,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/Cargo.toml.golden index c49607d95..ebe3d24ba 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for allOf intersection types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/apis/default.rs.golden index d4a0a4045..ec8fd559e 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/auth.rs.golden index 74456eb33..6d14ff92f 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/client.rs.golden index 0d9bbfe54..f78ef7002 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/error.rs.golden index 0cb7c517c..4303ee9be 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-allof/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/Cargo.toml.golden index e04b0730f..bfec5366e 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for allOf intersection types with nullable reference properties" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/apis/default.rs.golden index 37baa0070..df2829307 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/auth.rs.golden index ddca069d7..6049f1eee 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/client.rs.golden index 6e6149be6..5e6f07472 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/error.rs.golden index 56e7e1f8a..ba56b3bfe 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-intersection-with-nullable-reference/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/Cargo.toml.golden index f22374ace..a22ed7244 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for union types that reference other union types" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/apis/default.rs.golden index eefc89cc1..1f09b581a 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/auth.rs.golden index e6e96583e..c786fd06a 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/client.rs.golden index a459ddc25..0d71fe83f 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/error.rs.golden index 953eb9b77..36be0261d 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-nested-union/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/Cargo.toml.golden index 2d2783dd8..f704d5a6b 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for simple type aliases (not unions or intersections)" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/apis/default.rs.golden index 81c0f4ce8..3fe9f2fd9 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/auth.rs.golden index f447c84df..afa83280a 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/client.rs.golden index 768761fe0..7179f728d 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/error.rs.golden index e8ad0c121..d04f7c0fb 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-simple-type-alias/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/Cargo.toml.golden index d752c2001..a3f13eab1 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for union types with both interfaces and primitives" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/apis/default.rs.golden index d3817ae01..dad3d18b5 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/auth.rs.golden index fed0edd60..e841351cb 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/client.rs.golden index bad0a679e..dab88ac0e 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/error.rs.golden index 8788edb92..5d424ca0d 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-mixed/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/Cargo.toml.golden index 5211d826a..3f8accdfe 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for union types that include the any type" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/apis/default.rs.golden index d9a65dafc..b0f9b8c64 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/auth.rs.golden index ca570ea30..11fddef36 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/client.rs.golden index 7390352a1..b45d90fce 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/error.rs.golden index 2c1157566..d05cac14b 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-any/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/Cargo.toml.golden index e1740673a..753476399 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for union types (oneOf) with inline object schemas that should generate named interfaces" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/apis/default.rs.golden index 5ac3da7e7..c0c499155 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/auth.rs.golden index 4e60c6eb6..811899c72 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/client.rs.golden index f18ffad5d..ed7918aa4 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/error.rs.golden index 04e44136b..d0214da73 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-inline-objects/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/Cargo.toml.golden index 2082aafe8..d47395a79 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for oneOf/anyOf union types with interface members" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/apis/default.rs.golden index de5f9e998..5ac7be5f6 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/auth.rs.golden index 8a1d00fe8..02011e2dd 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/client.rs.golden index 2ac24c000..a55f90b92 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/error.rs.golden index 0be8c3429..4698556b4 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-interfaces/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/Cargo.toml.golden index 1a8a3b156..5e82a2d15 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for union types with primitive members" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/apis/default.rs.golden index 19f8819f2..9f4af81b9 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/auth.rs.golden index f2148ea9e..0914f201f 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/client.rs.golden index 23e469e74..2c1c6b905 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/error.rs.golden index 8008f52ab..49196aeca 100644 --- a/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/type-aliases-union-with-primitives/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/utoipa-mixed/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/utoipa-mixed/Cargo.toml.golden index bf19a46a6..85d98cc0e 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-mixed/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-mixed/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture covering all schema kinds with utoipa enabled" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/apis/default.rs.golden index 9362dd18b..c3ccec9e2 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/auth.rs.golden index 4e18eb8b0..f349e8a72 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/client.rs.golden index 8672f75c4..7dc78326a 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/error.rs.golden index 6b211f2f2..b07f63a26 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-mixed/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/Cargo.toml.golden index d42a20675..59fd2e06d 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test fixture for untagged union manual utoipa impl generation" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/apis/default.rs.golden index 7f0c6833f..f182937ec 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/auth.rs.golden index a28fbc5f1..a352b88df 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/client.rs.golden index 4560539c5..fdb67c230 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/error.rs.golden index d61431583..80b531572 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-untagged-union/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e) diff --git a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/Cargo.toml.golden b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/Cargo.toml.golden index bd6490dbe..a6d484be2 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/Cargo.toml.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/Cargo.toml.golden @@ -5,7 +5,7 @@ edition = "2024" description = "Test that utoipa::ToSchema is additive alongside user extra_derives" [dependencies] -aioduct = { version = "0.1.8", features = ["tokio", "rustls", "rustls-ring", "json"] } +aioduct = { version = "0.2", features = ["tokio", "rustls", "rustls-ring", "json"] } serde = { version = "1", features = ["derive"] } serde_json = "1" serde-xml-rs = "0.8.2" diff --git a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/apis/default.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/apis/default.rs.golden index e8e643c66..d51da259a 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/apis/default.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/apis/default.rs.golden @@ -8,13 +8,13 @@ use crate::runtime::client::Client; use crate::runtime::error::Error; /// API operations under the "default" tag. -pub struct DefaultApi<'a, R: aioduct::Runtime> { - client: &'a Client, +pub struct DefaultApi<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> { + client: &'a Client, } -impl<'a, R: aioduct::Runtime> DefaultApi<'a, R> { +impl<'a, R: aioduct::RuntimePoll, C: aioduct::ConnectorSend> DefaultApi<'a, R, C> { /// Create a new `DefaultApi` bound to the given client. - pub fn new(client: &'a Client) -> Self { + pub fn new(client: &'a Client) -> Self { Self { client, } diff --git a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/auth.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/auth.rs.golden index 7bb8a7aec..5d629bcaa 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/auth.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/auth.rs.golden @@ -9,12 +9,14 @@ use std::sync::Arc; use crate::runtime::error::Error; /// Trait for authenticating requests. -pub trait Authenticator: Send + Sync + std::fmt::Debug { +pub trait Authenticator: + Send + Sync + std::fmt::Debug +{ /// Apply authentication to the request builder. fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error>; + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error>; } /// Bearer token authentication. @@ -80,11 +82,11 @@ impl BearerAuth { } } -impl Authenticator for BearerAuth { +impl Authenticator for BearerAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let token = match &self.token { TokenSource::Static(t) => t.clone(), TokenSource::Dynamic(f) => f(), @@ -166,11 +168,11 @@ impl ApiKeyAuth { } } -impl Authenticator for ApiKeyAuth { +impl Authenticator for ApiKeyAuth { fn authenticate<'a>( &self, - req: aioduct::RequestBuilder<'a, R>, - ) -> Result, Error> { + req: aioduct::RequestBuilderSend<'a, R, C>, + ) -> Result, Error> { let key = match &self.api_key { KeySource::Static(k) => k.clone(), KeySource::Dynamic(f) => f(), diff --git a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/client.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/client.rs.golden index d74c382ff..a1edac234 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/client.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/client.rs.golden @@ -7,30 +7,30 @@ use std::fmt; use std::sync::Arc; -use aioduct::Runtime; - use crate::runtime::auth::Authenticator; use crate::runtime::error::Error; -/// Async HTTP client wrapping `aioduct::Client`. -pub struct Client { - inner: aioduct::Client, +/// Async HTTP client wrapping `aioduct::HttpEngineSend`. +pub struct Client { + inner: aioduct::HttpEngineSend, base_url: String, - authenticator: Option>>, + authenticator: Option>>, } -impl Client { +impl Client { /// Create a new client with the given base URL. pub fn new(base_url: &str) -> Self { Self { - inner: aioduct::Client::::with_rustls(), + inner: aioduct::HttpEngineSend::::with_rustls(), base_url: base_url.trim_end_matches('/').to_string(), authenticator: None, } } +} - /// Create a client with a custom `aioduct::Client`. - pub fn with_client(inner: aioduct::Client, base_url: &str) -> Self { +impl Client { + /// Create a client with a custom `aioduct::HttpEngineSend`. + pub fn with_client(inner: aioduct::HttpEngineSend, base_url: &str) -> Self { Self { inner, base_url: base_url.trim_end_matches('/').to_string(), @@ -39,7 +39,7 @@ impl Client { } /// Attach an authenticator to the client. - pub fn with_auth(mut self, auth: Arc>) -> Self { + pub fn with_auth(mut self, auth: Arc>) -> Self { self.authenticator = Some(auth); self } @@ -49,7 +49,7 @@ impl Client { } /// Build a GET request. - pub fn get(&self, path: &str) -> Result, Error> { + pub fn get(&self, path: &str) -> Result, Error> { let mut req = self.inner.get(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -58,7 +58,7 @@ impl Client { } /// Build a POST request. - pub fn post(&self, path: &str) -> Result, Error> { + pub fn post(&self, path: &str) -> Result, Error> { let mut req = self.inner.post(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -67,7 +67,7 @@ impl Client { } /// Build a PUT request. - pub fn put(&self, path: &str) -> Result, Error> { + pub fn put(&self, path: &str) -> Result, Error> { let mut req = self.inner.put(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -76,7 +76,7 @@ impl Client { } /// Build a DELETE request. - pub fn delete(&self, path: &str) -> Result, Error> { + pub fn delete(&self, path: &str) -> Result, Error> { let mut req = self.inner.delete(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -85,7 +85,7 @@ impl Client { } /// Build a PATCH request. - pub fn patch(&self, path: &str) -> Result, Error> { + pub fn patch(&self, path: &str) -> Result, Error> { let mut req = self.inner.patch(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -94,7 +94,7 @@ impl Client { } /// Build a HEAD request. - pub fn head(&self, path: &str) -> Result, Error> { + pub fn head(&self, path: &str) -> Result, Error> { let mut req = self.inner.head(&self.full_url(path))?; if let Some(auth) = &self.authenticator { req = auth.authenticate(req)?; @@ -103,7 +103,7 @@ impl Client { } } -impl fmt::Debug for Client { +impl fmt::Debug for Client { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("base_url", &self.base_url) diff --git a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/error.rs.golden b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/error.rs.golden index 044ae189a..ed87910b2 100644 --- a/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/error.rs.golden +++ b/tests/golden/rust/rust-aioduct/utoipa-with-extra-derives/src/runtime/error.rs.golden @@ -47,6 +47,12 @@ impl From for Error { } } +impl From for Error { + fn from(e: aioduct::SendError) -> Self { + Error::Http(e.into()) + } +} + impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Deserialize(e)