pub fn decode<'de, D, T>(decoder: D) -> Result<T, D::Error>Expand description
Decode a string and parse it through FromStr.
A parse error is reported through the decoder’s context, formatted through
its Display implementation.
§Examples
use std::net::Ipv4Addr;
use musli::Decode;
#[derive(Debug, PartialEq, Decode)]
struct Host {
#[musli(decode_with = musli::display::decode)]
address: Ipv4Addr,
}
let host: Host = musli::json::from_str(r#"{"address":"127.0.0.1"}"#)?;
assert_eq!(host, Host { address: Ipv4Addr::LOCALHOST });