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§
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>
Implementations§
source§impl dyn ModelField
impl dyn ModelField
sourcepub fn is<T: ModelField>(&self) -> bool
pub fn is<T: ModelField>(&self) -> bool
Returns true if the boxed type is the same as T
sourcepub fn downcast_ref<T: ModelField>(&self) -> Option<&T>
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.
sourcepub unsafe fn downcast_ref_unchecked<T: ModelField>(&self) -> &T
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.
sourcepub fn downcast_mut<T: ModelField>(&mut self) -> Option<&mut T>
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.
sourcepub unsafe fn downcast_mut_unchecked<T: ModelField>(&mut self) -> &mut T
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
impl dyn ModelField
sourcepub fn downcast<T: ModelField>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
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.
sourcepub unsafe fn downcast_unchecked<T: ModelField>(self: Box<Self>) -> Box<T>
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.