pub trait Encoding: Sealed + 'static {
const NAME: &'static str;
// Required method
fn max_size(sizes: &EncodedSizes) -> Option<u32>;
}Expand description
A payload encoding. Only the three marker types of this module implement it.
A crate outside ridl-rt names an encoding through this trait:
fn name<E: ridl_rt::encoding::Encoding>() -> &'static str {
E::NAME
}
assert_eq!(name::<ridl_rt::encoding::ReprC>(), "repr-c");and cannot add an encoding:
ⓘ
struct Json;
impl ridl_rt::encoding::Encoding for Json {
const NAME: &'static str = "json";
fn max_size(sizes: &ridl_rt::contract::EncodedSizes) -> Option<u32> {
sizes.proto3
}
}and cannot implement the sealing trait, because its module is private:
ⓘ
struct Json;
impl ridl_rt::encoding::sealed::Sealed for Json {}Required Associated Constants§
Required Methods§
Sourcefn max_size(sizes: &EncodedSizes) -> Option<u32>
fn max_size(sizes: &EncodedSizes) -> Option<u32>
This encoding’s field of sizes: a payload’s largest encoded size in
this encoding, or None when the toolchain cannot size it
(EncodedSizes).
A required item, so an encoding added without saying which field it reads does not compile.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".