Skip to main content

datex_core/values/value/
apply.rs

1use crate::{
2    prelude::*,
3    runtime::Runtime,
4    traits::apply::{Apply, ApplyArgument, ApplyError},
5    values::{value::Value, value_container::ValueContainer},
6};
7
8impl Apply for Value {
9    fn try_apply_sync(
10        &self,
11        runtime: &Runtime,
12        args: Vec<ApplyArgument>,
13    ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError> {
14        match self {
15            Value::Core(core_value) => core_value.try_apply_sync(runtime, args),
16            _ => Err(ApplyError::UnsupportedApply),
17        }
18    }
19
20    async fn try_apply_async(
21        &self,
22        runtime: &Runtime,
23        args: Vec<ApplyArgument>,
24    ) -> Result<(Option<ValueContainer>, Vec<ValueContainer>), ApplyError> {
25        match self {
26            Value::Core(core_value) => {
27                core_value.try_apply_async(runtime, args).await
28            }
29            _ => Err(ApplyError::UnsupportedApply),
30        }
31    }
32}