From d01ab537192a5d23118125cd25814ad1c2270d18 Mon Sep 17 00:00:00 2001 From: Uwe Pachler Date: Fri, 4 Oct 2024 21:55:02 +0200 Subject: [PATCH 1/5] add documentation on pre and post hooks to builder methods --- progenitor-impl/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 564c74da..95191090 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -135,18 +135,32 @@ impl GenerationSettings { } /// Hook invoked before issuing the HTTP request. + /// Any hook requires the inner type to be set via + /// [Self::with_inner_type], otherwise the code will not compile. + /// The signature for the pre hook function should be + /// `pre_hook_func(&InnerType, &request::Client) -> ()` pub fn with_pre_hook(&mut self, pre_hook: TokenStream) -> &mut Self { self.pre_hook = Some(pre_hook); self } /// Hook invoked before issuing the HTTP request. + /// Any hook requires the inner type to be set via + /// [Self::with_inner_type], otherwise the code will not compile. + /// The signature for the pre hook function should be + /// `pre_hook_async_func(&InnerType, &mut request::Client) -> Result<_,E>`. + /// Returning an error result will abort the call with + /// an `Error::PreHookError` (type declared in generated code). pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self { self.pre_hook_async = Some(pre_hook); self } /// Hook invoked prior to receiving the HTTP response. + /// Any hook requires the inner type to be set via + /// [Self::with_inner_type], otherwise the code will not compile. + /// The signature for the post hook function should be + /// `post_hook_func(&InnerType, &Result) -> ()` pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self { self.post_hook = Some(post_hook); self From 6cfbbd4ebfd61b1e072b0e19cb5ea188bf67c1f9 Mon Sep 17 00:00:00 2001 From: upachler Date: Tue, 26 Nov 2024 20:10:20 +0000 Subject: [PATCH 2/5] fixup docs after #933 was merged --- progenitor-impl/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 95191090..ff9abb7f 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -135,20 +135,20 @@ impl GenerationSettings { } /// Hook invoked before issuing the HTTP request. - /// Any hook requires the inner type to be set via - /// [Self::with_inner_type], otherwise the code will not compile. /// The signature for the pre hook function should be - /// `pre_hook_func(&InnerType, &request::Client) -> ()` + /// `pre_hook_func(&request::Client) -> ()` + /// or `pre_hook_func(&InnerType, &request::Client) -> ()` + /// if an inner type was provided using [`with_inner_type()`]. pub fn with_pre_hook(&mut self, pre_hook: TokenStream) -> &mut Self { self.pre_hook = Some(pre_hook); self } /// Hook invoked before issuing the HTTP request. - /// Any hook requires the inner type to be set via - /// [Self::with_inner_type], otherwise the code will not compile. /// The signature for the pre hook function should be - /// `pre_hook_async_func(&InnerType, &mut request::Client) -> Result<_,E>`. + /// `pre_hook_async_func(&mut request::Client) -> Result<_,E>`, + /// or `pre_hook_async_func(&InnerType, &mut request::Client) -> Result<_,E>` + /// if an inner type was provided using [`with_inner_type()`]. /// Returning an error result will abort the call with /// an `Error::PreHookError` (type declared in generated code). pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self { @@ -157,10 +157,10 @@ impl GenerationSettings { } /// Hook invoked prior to receiving the HTTP response. - /// Any hook requires the inner type to be set via - /// [Self::with_inner_type], otherwise the code will not compile. /// The signature for the post hook function should be - /// `post_hook_func(&InnerType, &Result) -> ()` + /// `post_hook_func(&Result) -> ()`, + /// or, `post_hook_func(&InnerType, &Result) -> ()` + /// if an inner type was provided using [`with_inner_type()`]. pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self { self.post_hook = Some(post_hook); self From 22bc190d7ee9f0568cd69d4786b97a66943d988e Mon Sep 17 00:00:00 2001 From: Uwe Pachler Date: Tue, 26 Nov 2024 21:58:33 +0100 Subject: [PATCH 3/5] fix links in rustdoc --- progenitor-impl/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 64111a0c..86b79010 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -139,7 +139,7 @@ impl GenerationSettings { /// The signature for the pre hook function should be /// `pre_hook_func(&request::Client) -> ()` /// or `pre_hook_func(&InnerType, &request::Client) -> ()` - /// if an inner type was provided using [`with_inner_type()`]. + /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). pub fn with_pre_hook(&mut self, pre_hook: TokenStream) -> &mut Self { self.pre_hook = Some(pre_hook); self @@ -149,7 +149,7 @@ impl GenerationSettings { /// The signature for the pre hook function should be /// `pre_hook_async_func(&mut request::Client) -> Result<_,E>`, /// or `pre_hook_async_func(&InnerType, &mut request::Client) -> Result<_,E>` - /// if an inner type was provided using [`with_inner_type()`]. + /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). /// Returning an error result will abort the call with /// an `Error::PreHookError` (type declared in generated code). pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self { @@ -160,8 +160,8 @@ impl GenerationSettings { /// Hook invoked prior to receiving the HTTP response. /// The signature for the post hook function should be /// `post_hook_func(&Result) -> ()`, - /// or, `post_hook_func(&InnerType, &Result) -> ()` - /// if an inner type was provided using [`with_inner_type()`]. + /// or `post_hook_func(&InnerType, &Result) -> ()` + /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self { self.post_hook = Some(post_hook); self From c750dfc25a969466008da8db4f4f3c6f84dea882 Mon Sep 17 00:00:00 2001 From: Uwe Pachler Date: Tue, 26 Nov 2024 22:41:37 +0100 Subject: [PATCH 4/5] add docs for with_post_hook_async() and structure alternative signatures for the others --- progenitor-impl/src/lib.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 86b79010..a42432d1 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -136,20 +136,21 @@ impl GenerationSettings { } /// Hook invoked before issuing the HTTP request. - /// The signature for the pre hook function should be - /// `pre_hook_func(&request::Client) -> ()` - /// or `pre_hook_func(&InnerType, &request::Client) -> ()` - /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). + /// The signature for the pre hook function should be either + /// * `pre_hook(&request::Client) -> ()` without an inner type, or + /// * `pre_hook(&InnerType, &request::Client) -> ()` + /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). pub fn with_pre_hook(&mut self, pre_hook: TokenStream) -> &mut Self { self.pre_hook = Some(pre_hook); self } /// Hook invoked before issuing the HTTP request. - /// The signature for the pre hook function should be - /// `pre_hook_async_func(&mut request::Client) -> Result<_,E>`, - /// or `pre_hook_async_func(&InnerType, &mut request::Client) -> Result<_,E>` - /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). + /// The signature for the pre hook function should be either + /// * `async pre_hook(&mut request::Client) -> Result<_,E>` without an inner type, or + /// * `async pre_hook(&InnerType, &mut request::Client) -> Result<_,E>` + /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). + /// /// Returning an error result will abort the call with /// an `Error::PreHookError` (type declared in generated code). pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self { @@ -158,16 +159,23 @@ impl GenerationSettings { } /// Hook invoked prior to receiving the HTTP response. - /// The signature for the post hook function should be - /// `post_hook_func(&Result) -> ()`, - /// or `post_hook_func(&InnerType, &Result) -> ()` - /// if an inner type was provided using [`with_inner_type()`](Self::with_inner_type). + /// The signature for the post hook function should be either + /// * `post_hook(&Result) -> ()` without an inner type, or + /// * `post_hook(&InnerType, &Result) -> ()` + /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self { self.post_hook = Some(post_hook); self } /// Hook invoked prior to receiving the HTTP response. + /// The signature for the post hook function should be either + /// * `async post_hook(&Result) -> ()` without an innter type, or + /// * `async post_hook(&InnerType, &Result) -> Result<_,E>` + /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). + /// + /// Returning an error result will abort the call with + /// an `Error::PostHookError` (type declared in generated code). pub fn with_post_hook_async( &mut self, post_hook: TokenStream, From d5ce16eda5c8cc8e10ec09bc1f9e910023892180 Mon Sep 17 00:00:00 2001 From: Uwe Pachler Date: Wed, 27 Nov 2024 00:04:32 +0100 Subject: [PATCH 5/5] cargo fmt --- progenitor-impl/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index a42432d1..bdf5b7d7 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -150,7 +150,7 @@ impl GenerationSettings { /// * `async pre_hook(&mut request::Client) -> Result<_,E>` without an inner type, or /// * `async pre_hook(&InnerType, &mut request::Client) -> Result<_,E>` /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). - /// + /// /// Returning an error result will abort the call with /// an `Error::PreHookError` (type declared in generated code). pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self { @@ -173,7 +173,7 @@ impl GenerationSettings { /// * `async post_hook(&Result) -> ()` without an innter type, or /// * `async post_hook(&InnerType, &Result) -> Result<_,E>` /// if an inner type was specified using [`with_inner_type()`](Self::with_inner_type). - /// + /// /// Returning an error result will abort the call with /// an `Error::PostHookError` (type declared in generated code). pub fn with_post_hook_async(