reifydb_evaluate/expression/
convert.rs1use reifydb_core::value::column::cast::convert::{Convert, TargetConvert};
5use reifydb_value::{
6 Result,
7 fragment::Fragment,
8 value::{number::safe::convert::SafeConvert, value_type::get::GetType},
9};
10
11use crate::expression::context::EvalContext;
12
13impl Convert for EvalContext<'_> {
14 fn convert<From, To>(&self, from: From, fragment: impl Into<Fragment>) -> Result<Option<To>>
15 where
16 From: SafeConvert<To> + GetType,
17 To: GetType,
18 {
19 Convert::convert(&self, from, fragment)
20 }
21}
22
23impl Convert for &EvalContext<'_> {
24 fn convert<From, To>(&self, from: From, fragment: impl Into<Fragment>) -> Result<Option<To>>
25 where
26 From: SafeConvert<To> + GetType,
27 To: GetType,
28 {
29 TargetConvert {
30 target: self.target.as_ref(),
31 }
32 .convert(from, fragment)
33 }
34}