Serializable

Trait Serializable 

Source
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§

Source

fn serialize(&self) -> Option<String>

Serializes the object into an optional string representation.

§Returns

An Option<String> containing the serialized representation, or None if serialization fails.

Provided Methods§

Source

fn set_metadata(&mut self, metadata: MetadataSchema)

Sets metadata for the object.

§Arguments
  • metadata: The metadata to set.
§Panics

This method panics if not implemented for the type.

Source

fn set_nullable(&mut self, nullable: bool)

Sets the nullability of the object.

§Arguments
  • nullable: A boolean indicating whether the object is nullable.
§Panics

This method panics if not implemented for the type.

Source

fn set_rename(&mut self, new_name: &str)

Renames the object.

§Arguments
  • new_name: The new name to assign to the object.
§Panics

This method panics if not implemented for the type.

Implementations§

Source§

impl dyn Serializable

Source

pub fn is<__T>(&self) -> bool
where __T: Serializable,

Returns true if the trait object wraps an object of type __T.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for dyn Serializable

Source§

fn eq(&self, other: &(dyn Serializable + 'static)) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serializable for Box<dyn Serializable>

Source§

fn serialize(&self) -> Option<String>

Serializes the object into an optional string representation. Read more
Source§

fn set_metadata(&mut self, metadata: MetadataSchema)

Sets metadata for the object. Read more
Source§

fn set_nullable(&mut self, nullable: bool)

Sets the nullability of the object. Read more
Source§

fn set_rename(&mut self, new_name: &str)

Renames the object. Read more
Source§

impl Eq for dyn Serializable

Implementations on Foreign Types§

Source§

impl Serializable for &'static str

Source§

impl Serializable for bool

Source§

impl Serializable for f32

Source§

impl Serializable for f64

Source§

impl Serializable for i8

Source§

impl Serializable for i16

Source§

impl Serializable for i32

Source§

impl Serializable for i64

Source§

impl Serializable for i128

Source§

impl Serializable for isize

Source§

impl Serializable for u8

Source§

impl Serializable for u16

Source§

impl Serializable for u32

Source§

impl Serializable for u64

Source§

impl Serializable for u128

Source§

impl Serializable for ()

Source§

impl Serializable for usize

Source§

impl Serializable for Box<dyn Serializable>

Source§

fn serialize(&self) -> Option<String>

Source§

fn set_metadata(&mut self, metadata: MetadataSchema)

Source§

fn set_nullable(&mut self, nullable: bool)

Source§

fn set_rename(&mut self, new_name: &str)

Source§

impl Serializable for String

Source§

impl<T> Serializable for Option<T>
where T: Serializable,

Source§

impl<T> Serializable for Box<T>
where T: Serializable,

Source§

fn serialize(&self) -> Option<String>

Source§

fn set_metadata(&mut self, metadata: MetadataSchema)

Source§

fn set_nullable(&mut self, nullable: bool)

Source§

fn set_rename(&mut self, new_name: &str)

Source§

impl<T> Serializable for Vec<T>
where T: Serializable,

Source§

impl<T> Serializable for HashMap<String, T>
where T: Serializable,

Implementors§