Trait hit_data::ModelField

source ·
pub trait ModelField: Any {
    // Required methods
    fn get_name(&self) -> String;
    fn validate(
        &self,
        value: &ObjectValue,
        context: &ValidatorContext<'_>
    ) -> Result<Option<Vec<ValidationError>>, HitError>;
    fn accepts_for_set(
        &self,
        value: &ObjectValue,
        context: &ValidatorContext<'_>
    ) -> bool;
    fn accepts_model(&self, model: &Model) -> bool;
    fn is_vec_reference(&self) -> bool;
    fn is_vec_subobject(&self) -> bool;
    fn on_kernel_init(&mut self, model_name: &str) -> Result<(), HitError>;
}

Required Methods§

source

fn get_name(&self) -> String

source

fn validate( &self, value: &ObjectValue, context: &ValidatorContext<'_> ) -> Result<Option<Vec<ValidationError>>, HitError>

source

fn accepts_for_set( &self, value: &ObjectValue, context: &ValidatorContext<'_> ) -> bool

source

fn accepts_model(&self, model: &Model) -> bool

source

fn is_vec_reference(&self) -> bool

source

fn is_vec_subobject(&self) -> bool

source

fn on_kernel_init(&mut self, model_name: &str) -> Result<(), HitError>

Implementations§

source§

impl dyn ModelField

source

pub fn is<T: ModelField>(&self) -> bool

Returns true if the boxed type is the same as T

source

pub fn downcast_ref<T: ModelField>(&self) -> Option<&T>

Returns some reference to the boxed value if it is of type T, or None if it isn’t.

source

pub unsafe fn downcast_ref_unchecked<T: ModelField>(&self) -> &T

Returns a reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

source

pub fn downcast_mut<T: ModelField>(&mut self) -> Option<&mut T>

Returns some mutable reference to the boxed value if it is of type T, or None if it isn’t.

source

pub unsafe fn downcast_mut_unchecked<T: ModelField>(&mut self) -> &mut T

Returns a mutable reference to the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

source§

impl dyn ModelField

source

pub fn downcast<T: ModelField>(self: Box<Self>) -> Result<Box<T>, Box<Self>>

Returns the boxed value if it is of type T, or Err(Self) if it isn’t.

source

pub unsafe fn downcast_unchecked<T: ModelField>(self: Box<Self>) -> Box<T>

Returns the boxed value, blindly assuming it to be of type T. If you are not absolutely certain of T, you must not call this.

Implementors§