pub trait WellKnown: 'static + Sized {
type Deserializer: DeserializeParam<Self>;
const DE: Self::Deserializer;
}Expand description
Parameter type with well-known deserializer.
Conceptually, this means that the type is known to behave well when deserializing data from a Value
(ordinarily, using serde::Deserialize).
§Implementations
Basic well-known types include:
These types use Serde deserializer. Integer types up to and including 64-bit ones
only permit integer input. In contrast, u128, i128 and their non-zero counterparts permit
either integer or string input because the serde_json object model cannot represent large
integers (>u64::MAX or <i64::MIN). Importantly, string representation must be used
for such large integers because otherwise they will be converted (with precision loss!) to f64
by internal serde_json logic before they ever enter the smart-config library.
WellKnown is also implemented for more complex types:
| Rust type | Deserializer | Expected JSON |
|---|---|---|
Duration | WithUnit | string or object |
ByteSize | WithUnit | string or object |
Option | Optional† | value, or null, or nothing |
Vec, [_; N], HashSet, BTreeSet | Repeated | array |
HashMap, BTreeMap | RepeatedEntries | object |
† Options handling can be customized via WellKnownOption or CustomKnownOption traits.
Required Associated Constants§
Sourceconst DE: Self::Deserializer
const DE: Self::Deserializer
Deserializer instance.
Required Associated Types§
Sourcetype Deserializer: DeserializeParam<Self>
type Deserializer: DeserializeParam<Self>
Type of the deserializer used for this type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl WellKnown for IpAddr
impl WellKnown for IpAddr
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for SocketAddr
impl WellKnown for SocketAddr
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for bool
impl WellKnown for bool
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for f32
impl WellKnown for f32
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for f64
impl WellKnown for f64
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for i8
impl WellKnown for i8
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for i16
impl WellKnown for i16
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for i32
impl WellKnown for i32
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for i64
impl WellKnown for i64
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for i128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
impl WellKnown for i128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for isize
impl WellKnown for isize
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for u8
impl WellKnown for u8
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for u16
impl WellKnown for u16
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for u32
impl WellKnown for u32
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for u64
impl WellKnown for u64
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for u128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
impl WellKnown for u128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for usize
impl WellKnown for usize
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for String
impl WellKnown for String
const DE: Self::Deserializer
type Deserializer = Serde<{ $crate::_basic_types!($($expecting)+) }>
Source§impl WellKnown for Ipv4Addr
impl WellKnown for Ipv4Addr
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for Ipv6Addr
impl WellKnown for Ipv6Addr
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for SocketAddrV4
impl WellKnown for SocketAddrV4
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for SocketAddrV6
impl WellKnown for SocketAddrV6
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for Duration
impl WellKnown for Duration
const DE: Self::Deserializer = WithUnit
type Deserializer = WithUnit
Source§impl WellKnown for PathBuf
impl WellKnown for PathBuf
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroI8
impl WellKnown for NonZeroI8
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroI16
impl WellKnown for NonZeroI16
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroI32
impl WellKnown for NonZeroI32
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroI64
impl WellKnown for NonZeroI64
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroI128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
impl WellKnown for NonZeroI128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroIsize
impl WellKnown for NonZeroIsize
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroU8
impl WellKnown for NonZeroU8
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroU16
impl WellKnown for NonZeroU16
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroU32
impl WellKnown for NonZeroU32
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroU64
impl WellKnown for NonZeroU64
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroU128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
impl WellKnown for NonZeroU128
Unlike other ints, we allow str inputs for 128-bit ints because serde_json::Value doesn’t support
representing 128-bit numbers natively.
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for NonZeroUsize
impl WellKnown for NonZeroUsize
const DE: Self::Deserializer
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for Address
Available on crate feature alloy only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for Address
alloy only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for B64
Available on crate feature alloy only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for B64
alloy only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for B128
Available on crate feature alloy only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for B128
alloy only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for B256
Available on crate feature alloy only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for B256
alloy only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for B512
Available on crate feature alloy only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for B512
alloy only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H128
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H128
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H160
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H160
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H256
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H256
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H384
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H384
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H512
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H512
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for H768
Available on crate feature primitive-types only.Accepts a hex string with an optional 0x prefix.
impl WellKnown for H768
primitive-types only.Accepts a hex string with an optional 0x prefix.
const DE: Self::Deserializer = HASH_DE
type Deserializer = Qualified<Serde<{ $crate::_basic_types!($($expecting)+) }>>
Source§impl WellKnown for U8
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U8
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U16
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U16
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U32
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U32
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U64
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U64
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U128
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U128
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U128
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U128
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U160
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U160
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U256
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U256
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U256
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U256
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U512
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U512
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
const DE: Self::Deserializer = HexUintDeserializer
type Deserializer = HexUintDeserializer
Source§impl WellKnown for U512
Available on crate feature primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.
impl WellKnown for U512
primitive-types only.Accepts a hex string with an mandatory 0x prefix. This prefix is required to clearly signal hex encoding
so that "34" doesn’t get mistaken for decimal 34.