vortex_scalar/scalar_value/
bool.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use vortex_error::{VortexError, VortexResult, vortex_err};
5
6use crate::ScalarValue;
7
8impl TryFrom<&ScalarValue> for bool {
9    type Error = VortexError;
10
11    fn try_from(value: &ScalarValue) -> VortexResult<Self> {
12        <Option<bool>>::try_from(value)?
13            .ok_or_else(|| vortex_err!("Can't extract present value from null scalar"))
14    }
15}
16
17impl TryFrom<&ScalarValue> for Option<bool> {
18    type Error = VortexError;
19
20    fn try_from(value: &ScalarValue) -> VortexResult<Self> {
21        value.as_bool()
22    }
23}