rbdc_sqlite/types/
str.rs

1use 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 String {
9    fn type_info(&self) -> SqliteTypeInfo {
10        SqliteTypeInfo(DataType::Text)
11    }
12}
13
14impl Encode for String {
15    fn encode(self, args: &mut Vec<SqliteArgumentValue>) -> Result<IsNull, Error> {
16        args.push(SqliteArgumentValue::Text(self));
17
18        Ok(IsNull::No)
19    }
20}
21
22impl Decode for String {
23    fn decode(value: SqliteValue) -> Result<Self, Error> {
24        value.text().map(ToOwned::to_owned)
25    }
26}