lyra-engine/lyra-reflect/src/field.rs

21 lines
490 B
Rust
Raw Normal View History

2023-12-30 23:55:05 +00:00
use std::{any::TypeId, sync::Arc};
use super::Value;
#[derive(Clone)]
pub struct Field {
pub name: String,
pub type_id: TypeId,
pub(crate) getter: Option<Arc<dyn Fn(&Value) -> Value>>,
pub(crate) setter: Option<Arc<dyn Fn(&mut Value, Value)>>,
}
impl Field {
pub fn getter_fn(&self) -> Option<Arc<dyn Fn(&Value) -> Value>> {
self.getter.clone()
}
pub fn setter_fn(&self) -> Option<Arc<dyn Fn(&mut Value, Value)>> {
self.setter.clone()
}
}