assembly_fdb_core/value/
mem.rs1use latin1str::Latin1Str;
4
5use super::{Context, Value};
6
7#[derive(Debug, PartialEq, Eq)]
8pub struct MemContext<'a> {
10 _m: std::marker::PhantomData<fn() -> &'a ()>,
11}
12
13impl<'a> Context for MemContext<'a> {
14 type String = &'a Latin1Str;
15 type I64 = i64;
16 type XML = &'a Latin1Str;
17}
18
19pub type Field<'a> = Value<MemContext<'a>>;
21
22#[cfg(feature = "sqlite")]
23impl<'a> rusqlite::ToSql for Field<'a> {
24 fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
25 use rusqlite::types::ToSqlOutput;
26 use std::borrow::Cow;
27 Ok(match *self {
28 Field::Nothing => ToSqlOutput::Owned(rusqlite::types::Value::Null),
29 Field::Integer(i) => i.into(),
30 Field::Float(f) => f.into(),
31 Field::Boolean(b) => b.into(),
32 Field::BigInt(i) => i.into(),
33 Field::Text(s) | Field::VarChar(s) => match s.decode() {
34 Cow::Owned(s) => ToSqlOutput::from(s),
35 Cow::Borrowed(s) => ToSqlOutput::from(s),
36 },
37 })
38 }
39}