pub trait JsonSerializable<E>: Serialize + for<'de> DeserializeOwned {
// Required methods
fn to_json_string(&self) -> Result<String, E>;
fn from_json_str(s: &str) -> Result<Self, E>;
}Expand description
Trait for types that can be serialized to/from JSON strings with specific error handling.
This provides a consistent interface for JSON operations throughout the framework.
Unlike the other utilities in this module which work with JsonError, this trait
is generic over the error type to allow different modules to use their own error types.
Required Methods§
Sourcefn to_json_string(&self) -> Result<String, E>
fn to_json_string(&self) -> Result<String, E>
Sourcefn from_json_str(s: &str) -> Result<Self, E>
fn from_json_str(s: &str) -> Result<Self, E>
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.
Implementors§
impl<T> JsonSerializable<PersistenceError> for Twhere
T: Serialize + for<'de> DeserializeOwned,
Blanket implementation of JsonSerializable for all suitable types using PersistenceError.