Struct config_it::entity::Metadata

source ·
pub struct Metadata {
    pub name: &'static str,
    pub type_id: TypeId,
    pub v_default: Arc<dyn EntityTrait>,
    pub v_min: Option<Box<dyn EntityTrait>>,
    pub v_max: Option<Box<dyn EntityTrait>>,
    pub v_one_of: Vec<Box<dyn EntityTrait>>,
    pub props: MetadataProps,
    pub fn_default: fn() -> Box<dyn EntityTrait>,
    pub fn_copy_to: fn(_: &dyn Any, _: &mut dyn Any),
    pub fn_serialize_to: fn(_: &dyn Any, _: &mut dyn Serializer) -> Result<(), Error>,
    pub fn_deserialize_from: fn(_: &mut dyn Any, _: &mut dyn Deserializer<'_>) -> Result<(), Error>,
    pub fn_validate: fn(_: &Metadata, _: &mut dyn Any) -> Option<bool>,
}
Expand description

Metadata for configuration entity. This can be used as template for multiple config entity instances.

Fields§

§name: &'static str

Identifier for this config entity.

§type_id: TypeId§v_default: Arc<dyn EntityTrait>§v_min: Option<Box<dyn EntityTrait>>§v_max: Option<Box<dyn EntityTrait>>§v_one_of: Vec<Box<dyn EntityTrait>>§props: MetadataProps§fn_default: fn() -> Box<dyn EntityTrait>§fn_copy_to: fn(_: &dyn Any, _: &mut dyn Any)§fn_serialize_to: fn(_: &dyn Any, _: &mut dyn Serializer) -> Result<(), Error>§fn_deserialize_from: fn(_: &mut dyn Any, _: &mut dyn Deserializer<'_>) -> Result<(), Error>§fn_validate: fn(_: &Metadata, _: &mut dyn Any) -> Option<bool>

Returns None if validation failed. Some(false) when source value was corrected. Some(true) when value was correct.

Implementations§

source§

impl Metadata

source

pub fn create_for_base_type<T>( name: &'static str, init: MetadataValInit<T>, props: MetadataProps ) -> Selfwhere T: EntityTrait + Default + Clone + DeserializeOwned + Serialize,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.