pub trait StaticCodec: Codec {
type Config<'de>: Serialize + Deserialize<'de> + JsonSchema;
const CODEC_ID: &'static str;
// Required methods
fn from_config(config: Self::Config<'_>) -> Self;
fn get_config(&self) -> StaticCodecConfig<'_, Self>;
}
Expand description
Statically typed compression codec.
Required Associated Constants§
Required Associated Types§
Sourcetype Config<'de>: Serialize + Deserialize<'de> + JsonSchema
type Config<'de>: Serialize + Deserialize<'de> + JsonSchema
Configuration type, from which the codec can be created infallibly.
The config
must not contain an id
field.
The config must be compatible with JSON encoding and have a schema.
Required Methods§
Sourcefn from_config(config: Self::Config<'_>) -> Self
fn from_config(config: Self::Config<'_>) -> Self
Instantiate a codec from its config
uration.
Sourcefn get_config(&self) -> StaticCodecConfig<'_, Self>
fn get_config(&self) -> StaticCodecConfig<'_, Self>
Get the configuration for this codec.
The StaticCodecConfig
ensures that the returned config includes an
id
field with the codec’s StaticCodec::CODEC_ID
.
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.