Skip to main content

datex_core/values/value/
value_access.rs

1use crate::{
2    shared_values::errors::AccessError,
3    traits::value_access::ValueAccess,
4    values::{
5        value::Value,
6        value_container::{
7            ValueContainer,
8            borrowed_value_container::{
9                BorrowedValueContainer, BorrowedValueContainerMut,
10            },
11        },
12    },
13};
14
15impl ValueAccess for Value {
16    fn try_get_property(
17        &self,
18        key: &ValueContainer,
19    ) -> Result<BorrowedValueContainer<'_>, AccessError> {
20        match &self {
21            Value::Core(core) => core.try_get_property(key),
22            Value::Native(native) => native.try_get_property(key),
23        }
24    }
25
26    fn try_get_property_mut(
27        &mut self,
28        key: &ValueContainer,
29    ) -> Result<BorrowedValueContainerMut<'_>, AccessError> {
30        match self {
31            Value::Core(core) => core.try_get_property_mut(key),
32            Value::Native(native) => native.try_get_property_mut(key),
33        }
34    }
35}