From 71ccf335d061c9c752d9a3b9d820b2274917f5ad Mon Sep 17 00:00:00 2001 From: MicroPanda123 Date: Mon, 18 Nov 2024 22:25:36 +0100 Subject: [PATCH] updated zasa --- server/Cargo.lock | 18 +++++++++++++++++- server/Cargo.toml | 2 +- server/src/main.rs | 23 ++--------------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index ede6a0a..8683f50 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1894,9 +1894,25 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "zasa" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e406a4941ce0c5351a09bb1d30e93744f430f80ffebcb1687f1550cff4553de4" +dependencies = [ + "zasa_core", + "zasa_derive", +] + +[[package]] +name = "zasa_core" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bd6fe2c1435fa0bd5ab924aba1f8f18f70e87735c142ede178a4fb14f9e85ed" +checksum = "828c3c824073e930389d33e932d376504bc88acf89be3c05bfa9bb406a09e52f" + +[[package]] +name = "zasa_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3f2e32a4c0a55c14568fee40a9ca566193d0c78d62282cb451e38f9defc5ec" [[package]] name = "zerocopy" diff --git a/server/Cargo.toml b/server/Cargo.toml index 039b047..bfc4a39 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -8,4 +8,4 @@ env_logger = "0.11.3" ntex = { version = "2.0.0", features = [ "tokio", "rustls" ] } ntex-files = "2.0.0" rand = "0.8.5" -zasa = "0.3.0" +zasa = { version = "0.4.0", features = [ "derive" ] } diff --git a/server/src/main.rs b/server/src/main.rs index fa5b877..c324c10 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -6,33 +6,14 @@ use ntex::{ web::{self, middleware}, }; use ntex_files as nfs; -use std::collections::HashMap; -use zasa::{ - parser::Parser, - value::{normalize, Normalize, Value, ValueError}, -}; +use zasa::{parser::Parser, value::normalize, Normalize}; -#[derive(Clone)] +#[derive(Clone, Normalize)] struct WebringMember { name: String, site: String, } -impl Normalize for WebringMember { - fn normalize(value: Value) -> Result { - match value { - Value::Object(a) => { - let member = WebringMember { - name: a["name"].to_string(), - site: a["site"].to_string(), - }; - Ok(member) - } - _ => Err(ValueError::ValueNotArray), - } - } -} - #[web::get("/next/{name}")] async fn next( members: web::types::State>,