pub trait Serializable: Downcast {
// Required method
fn serialize(&self) -> Option<String>;
// Provided methods
fn set_metadata(&mut self, metadata: MetadataSchema) { ... }
fn set_nullable(&mut self, nullable: bool) { ... }
fn set_rename(&mut self, new_name: &str) { ... }
}Expand description
A trait for types that can be serialized into a string representation.
This trait also provides default implementations for setting metadata, nullability, and renaming, which trigger a panic if not implemented.
Required Methods§
Provided Methods§
Sourcefn set_metadata(&mut self, metadata: MetadataSchema)
fn set_metadata(&mut self, metadata: MetadataSchema)
Sourcefn set_nullable(&mut self, nullable: bool)
fn set_nullable(&mut self, nullable: bool)
Sourcefn set_rename(&mut self, new_name: &str)
fn set_rename(&mut self, new_name: &str)
Implementations§
Source§impl dyn Serializable
impl dyn Serializable
Sourcepub fn is<__T>(&self) -> boolwhere
__T: Serializable,
pub fn is<__T>(&self) -> boolwhere
__T: Serializable,
Returns true if the trait object wraps an object of type __T.
Sourcepub fn downcast<__T>(
self: Box<dyn Serializable>,
) -> Result<Box<__T>, Box<dyn Serializable>>where
__T: Serializable,
pub fn downcast<__T>(
self: Box<dyn Serializable>,
) -> Result<Box<__T>, Box<dyn Serializable>>where
__T: Serializable,
Returns a boxed object from a boxed trait object if the underlying object is of type
__T. Returns the original boxed trait if it isn’t.
Sourcepub fn downcast_rc<__T>(
self: Rc<dyn Serializable>,
) -> Result<Rc<__T>, Rc<dyn Serializable>>where
__T: Serializable,
pub fn downcast_rc<__T>(
self: Rc<dyn Serializable>,
) -> Result<Rc<__T>, Rc<dyn Serializable>>where
__T: Serializable,
Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of
type __T. Returns the original Rc-ed trait if it isn’t.
Sourcepub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: Serializable,
pub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: Serializable,
Returns a reference to the object within the trait object if it is of type __T, or
None if it isn’t.
Sourcepub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: Serializable,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: Serializable,
Returns a mutable reference to the object within the trait object if it is of type
__T, or None if it isn’t.
Trait Implementations§
Source§impl Debug for dyn Serializable
impl Debug for dyn Serializable
Source§impl PartialEq for dyn Serializable
impl PartialEq for dyn Serializable
Source§fn eq(&self, other: &(dyn Serializable + 'static)) -> bool
fn eq(&self, other: &(dyn Serializable + 'static)) -> bool
self and other values to be equal, and is used by ==.