21 lines
490 B
Rust
21 lines
490 B
Rust
|
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()
|
||
|
}
|
||
|
}
|