mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-20 11:38:48 +00:00
a59626c971
openidconnect -> 2.5 base64 -> 0.21 url -> 2.3 bytes -> 1.3 |
||
---|---|---|
.. | ||
src | ||
tests | ||
.cargo-checksum.json | ||
Cargo.toml | ||
CHANGELOG | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md |
Serde Plain
This crate implements a plain text serializer and deserializer. It can only
serialize and deserialize primitives and derivatives thereof (like basic enums
or newtypes). It internally uses the FromStr
and Display
trait to convert
objects around.
From String
To parse a value from a string the from_str helper can be used:
assert_eq!(serde_plain::from_str::<i32>("42").unwrap(), 42);
This is particularly useful if enums are in use:
use serde::Deserialize;
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub enum MyEnum {
VariantA,
VariantB,
}
assert_eq!(serde_plain::from_str::<MyEnum>("VariantA").unwrap(), MyEnum::VariantA);
To String
The inverse is also possible with to_string:
assert_eq!(serde_plain::to_string(&true).unwrap(), "true");