pub trait Codec:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn encode_value(&self, value: &Value) -> AppResult<String>;
fn decode_value(&self, contents: &str) -> AppResult<Value>;
}Expand description
Object-safe contract for a structured-text codec over the Value model.
Implementations encode and decode one on-disk/text representation (TOML,
JSON, …) to and from serde_json::Value. The trait is intentionally
object-safe so a codec can be held as Arc<dyn Codec> and selected at
runtime; type-driven conversions live in the free functions encode and
decode.
Required Methods§
Sourcefn encode_value(&self, value: &Value) -> AppResult<String>
fn encode_value(&self, value: &Value) -> AppResult<String>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".