sqlx_exasol_impl/types/
bool.rs1use serde::Deserialize;
2use sqlx_core::{
3 decode::Decode,
4 encode::{Encode, IsNull},
5 error::BoxDynError,
6 types::Type,
7};
8
9use crate::{
10 arguments::ExaBuffer,
11 database::Exasol,
12 type_info::{ExaDataType, ExaTypeInfo},
13 types::ExaHasArrayType,
14 value::ExaValueRef,
15};
16
17impl Type<Exasol> for bool {
18 fn type_info() -> ExaTypeInfo {
19 ExaDataType::Boolean.into()
20 }
21}
22
23impl ExaHasArrayType for bool {}
24
25impl Encode<'_, Exasol> for bool {
26 fn encode_by_ref(&self, buf: &mut ExaBuffer) -> Result<IsNull, BoxDynError> {
27 buf.append(self)?;
28 Ok(IsNull::No)
29 }
30
31 fn size_hint(&self) -> usize {
32 5
34 }
35}
36
37impl Decode<'_, Exasol> for bool {
38 fn decode(value: ExaValueRef<'_>) -> Result<Self, BoxDynError> {
39 <Self as Deserialize>::deserialize(value.value).map_err(From::from)
40 }
41}