ferroui_base/data/
indexer_binding.rs1use crate::data::core::IndexerBindingExpression;
2use crate::data::{BindingBase, BindingExpressionBase, BindingMode};
3use crate::{FerroObject, FerroProperty, Ref};
4use std::rc::Rc;
5
6#[derive(Clone)]
9pub struct IndexerBinding {
10 source: Ref<FerroObject>,
11 pub property: &'static FerroProperty,
13 mode: BindingMode,
14}
15
16impl IndexerBinding {
17 pub fn new(source: Ref<FerroObject>, property: &'static FerroProperty, mode: BindingMode) -> Self {
18 Self { source, property, mode }
19 }
20
21 pub fn source(&self) -> &Ref<FerroObject> {
22 &self.source
23 }
24
25 pub fn mode(&self) -> BindingMode {
26 self.mode
27 }
28}
29
30impl BindingBase for IndexerBinding {
31 fn as_any(&self) -> Option<&dyn std::any::Any> {
32 Some(self)
33 }
34
35 fn create_instance(
36 &self,
37 target: &FerroObject,
38 target_property: Option<&'static FerroProperty>,
39 _anchor: Option<&Ref<FerroObject>>,
40 ) -> Rc<dyn BindingExpressionBase> {
41 IndexerBindingExpression::new(&self.source, self.property, target, target_property, self.mode)
42 }
43}