evo_framework/framework/entity/ientity.rs
use crate::framework::ievo::IEvo;
use std::error::Error;
/// A base trait representing an object-safe entity, commonly used for
/// serialization, deserialization, and string representation.
pub trait IEntity: IEvo {
/// Serializes the object into a vector of bytes.
///
/// # Returns
///
/// - `Ok(Vec<u8>)` containing the serialized bytes if successful.
/// - `Err(Box<dyn Error>)` if serialization fails.
fn to_bytes(&self) -> Result<Vec<u8>, Box<dyn Error>>;
/// Deserializes an object from a slice of bytes.
///
/// # Arguments
///
/// - `data` - A slice of bytes representing the serialized object.
///
/// # Returns
///
/// - `Ok(Self)` if deserialization is successful.
/// - `Err(Box<dyn Error>)` if deserialization fails.
fn from_bytes(data: &[u8]) -> Result<Self, Box<dyn Error>>
where
Self: Sized;
/// Outputs a human-readable string representation of the object.
fn to_string(&self) -> String;
}