From 80660c80a74b66df6f8a1e48e24b850d758c74be Mon Sep 17 00:00:00 2001 From: Piotr Orzechowski Date: Wed, 13 Mar 2024 09:25:35 +0100 Subject: [PATCH] Group functions and structs together --- src/routes/subscriptions.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/routes/subscriptions.rs b/src/routes/subscriptions.rs index 8221417..d544f34 100644 --- a/src/routes/subscriptions.rs +++ b/src/routes/subscriptions.rs @@ -198,22 +198,6 @@ async fn send_confirmation_email( }) } -#[derive(Deserialize)] -struct FormData { - name: String, - email: String, -} - -impl TryFrom for NewSubscriber { - type Error = String; - - fn try_from(value: FormData) -> Result { - let email = SubscriberEmail::parse(value.email)?; - let name = SubscriberName::parse(value.name)?; - Ok(NewSubscriber { email, name }) - } -} - #[tracing::instrument( name = "Storing subscription token in the database", skip(transaction, subscription_token) @@ -240,6 +224,22 @@ async fn store_token( Ok(()) } +#[derive(Deserialize)] +struct FormData { + name: String, + email: String, +} + +impl TryFrom for NewSubscriber { + type Error = String; + + fn try_from(value: FormData) -> Result { + let email = SubscriberEmail::parse(value.email)?; + let name = SubscriberName::parse(value.name)?; + Ok(NewSubscriber { email, name }) + } +} + #[derive(Template)] #[template(path = "welcome.html")] struct HtmlBodyTemplate<'a> {