rbdc_sqlite/types/
bool.rs1use crate::decode::Decode;
2use crate::encode::{Encode, IsNull};
3use crate::type_info::DataType;
4use crate::types::Type;
5use crate::{SqliteArgumentValue, SqliteTypeInfo, SqliteValue};
6use rbdc::error::Error;
7
8impl Type for bool {
9 fn type_info(&self) -> SqliteTypeInfo {
10 SqliteTypeInfo(DataType::Bool)
11 }
12}
13
14impl Encode for bool {
15 fn encode(self, args: &mut Vec<SqliteArgumentValue>) -> Result<IsNull, Error> {
16 args.push(SqliteArgumentValue::Int(i32::from(self)));
17
18 Ok(IsNull::No)
19 }
20}
21
22impl Decode for bool {
23 fn decode(value: SqliteValue) -> Result<bool, Error> {
24 Ok(value.int() != 0)
25 }
26}