Skip to content
Merged

v0.3 #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
resolver = "2"
resolver = "3"
members = ["serdev", "serdev_derive"]
exclude = ["examples"]

[workspace.package]
version = "0.2.1"
edition = "2021"
version = "0.3.0"
edition = "2024"
authors = ["kanarus <mail@kanarus.dev>"]
homepage = "https://crates.io/crates/serdev"
repository = "https://github.com/ohkami-rs/serdev"
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

```toml
[dependencies]
serdev = "0.2"
serdev = "0.3"
serde_json = "1.0"
```

Expand Down Expand Up @@ -67,18 +67,17 @@ Of course, you can use it in combination with some validation tools like [valida
Automatically validate by the `function` in deserialization. The `function` must be an *expression* that is
callable as type `fn(&self) -> Result<(), impl Display>` (of course the error type must be known at compile time).

(*expression*: including name or path to a `fn` or a method, an inlined closure as above, or even a block expression or function calling
or anything that are evaluated as `fn(&self) -> Result<(), impl Display>`)
(*expression*: name or path to a `fn` or a method, an inlined closure as above, or even a block expression or function calling
or anything that are finally evaluated as `fn(&self) -> Result<(), impl Display>`)

Errors are converted to a `String` internally and passed to `serde::de::Error::custom`.

- `#[serde(validate(by = "function", error = "Type"))]`

Using given `Type` for validation error without internal conversion.
Using given `Type` for the validation error, without conversion.
The `function` signature must explicitly return `Result<(), Type>`.

This may be preferred when you need better performance _even in error cases_.\
For **no-std** use, this is the only way supported.
This will be preferred in **no-std** use, or, maybe when you need better performance in error cases.

Both `"function"` and `"Type"` above accept path like `"crate::util::validate"`.

Expand Down
2 changes: 1 addition & 1 deletion serdev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = { workspace = true }
license = { workspace = true }

[dependencies]
serdev_derive = { version = "=0.2.1", path = "../serdev_derive" }
serdev_derive = { version = "=0.3.0", path = "../serdev_derive" }
serde = { version = "1", features = ["derive"] }

[dev-dependencies]
Expand Down