pub trait Serializable:
Serialize
+ for<'de> Deserialize<'de>
+ Send
+ Sync
+ 'static {
// Required method
fn namespace() -> Vec<String>;
// Provided methods
fn is_serializable() -> bool { ... }
fn to_json(&self) -> Result<String> { ... }
fn to_json_pretty(&self) -> Result<String> { ... }
fn from_json(json: &str) -> Result<Self>
where Self: Sized { ... }
fn to_dict(&self) -> Result<HashMap<String, Value>> { ... }
fn from_dict(dict: &HashMap<String, Value>) -> Result<Self>
where Self: Sized { ... }
fn type_name() -> &'static str { ... }
}
Expand description
Trait for objects that can be serialized and deserialized
This trait provides a standardized way to serialize FerricLink objects to and from various formats, similar to LangChain’s Serializable interface.
Required Methods§
Provided Methods§
Sourcefn is_serializable() -> bool
fn is_serializable() -> bool
Check if this object is serializable
By default, all objects implementing this trait are serializable. Override this method to provide custom serialization logic.
Sourcefn to_json_pretty(&self) -> Result<String>
fn to_json_pretty(&self) -> Result<String>
Serialize this object to a pretty-printed JSON string
Sourcefn to_dict(&self) -> Result<HashMap<String, Value>>
fn to_dict(&self) -> Result<HashMap<String, Value>>
Serialize this object to a dictionary (HashMap)
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.