pub trait EncodingStrategy<T> {
type Context: Default + Clone;
// Required methods
fn encode<E: EntropyCoder>(
value: &T,
writer: &mut E,
ctx: &mut Self::Context,
);
fn decode<D: EntropyDecoder>(
reader: &mut D,
ctx: &mut Self::Context,
) -> Result<T, Error>;
}Expand description
An encoding strategy for type T.
You can implement this for your own types, if you want them to support
e.g. Small encodings. But I expect this to be unusual. It would be
possible to create a Derive macro for this, but I don’t think it is
needed. If you want such a macro file an issue.
Note that besides implementing existing strategies for your own types, you
can also create entirely new strategies in your crates. If you do that, you
can use full paths in your derive macros, e.g.
#[compactly(your_crate::SuperCoolEncodingStratgy].
Required Associated Types§
Required Methods§
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.