updated zasa

This commit is contained in:
MicroPanda123 2024-11-18 22:25:36 +01:00
parent 4a78061dba
commit 71ccf335d0
No known key found for this signature in database
3 changed files with 20 additions and 23 deletions

18
server/Cargo.lock generated
View file

@ -1894,9 +1894,25 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]] [[package]]
name = "zasa" 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" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" 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]] [[package]]
name = "zerocopy" name = "zerocopy"

View file

@ -8,4 +8,4 @@ env_logger = "0.11.3"
ntex = { version = "2.0.0", features = [ "tokio", "rustls" ] } ntex = { version = "2.0.0", features = [ "tokio", "rustls" ] }
ntex-files = "2.0.0" ntex-files = "2.0.0"
rand = "0.8.5" rand = "0.8.5"
zasa = "0.3.0" zasa = { version = "0.4.0", features = [ "derive" ] }

View file

@ -6,33 +6,14 @@ use ntex::{
web::{self, middleware}, web::{self, middleware},
}; };
use ntex_files as nfs; use ntex_files as nfs;
use std::collections::HashMap; use zasa::{parser::Parser, value::normalize, Normalize};
use zasa::{
parser::Parser,
value::{normalize, Normalize, Value, ValueError},
};
#[derive(Clone)] #[derive(Clone, Normalize)]
struct WebringMember { struct WebringMember {
name: String, name: String,
site: String, site: String,
} }
impl Normalize for WebringMember {
fn normalize(value: Value) -> Result<Self, ValueError> {
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}")] #[web::get("/next/{name}")]
async fn next( async fn next(
members: web::types::State<Vec<WebringMember>>, members: web::types::State<Vec<WebringMember>>,