sqlx_cloudflare_d1/
value.rs1use std::borrow::Cow;
2
3use sqlx_cloudflare_core::{AsValue, Value as CoreValue};
4use sqlx_core::value::{Value, ValueRef};
5
6use crate::{D1TypeInfo, D1};
7
8#[derive(Debug, Clone, PartialEq)]
16pub struct D1Value(pub(crate) CoreValue);
17
18impl Value for D1Value {
19 type Database = D1;
20
21 fn as_ref(&self) -> D1ValueRef<'_> {
22 D1ValueRef(&self.0)
23 }
24
25 fn type_info(&self) -> Cow<'_, D1TypeInfo> {
26 Cow::Owned(self.0.type_info())
27 }
28
29 fn is_null(&self) -> bool {
30 self.0.is_null()
31 }
32}
33
34#[derive(Debug, Clone, Copy)]
36pub struct D1ValueRef<'r>(pub(crate) &'r CoreValue);
37
38impl<'r> AsValue<'r> for D1ValueRef<'r> {
39 fn as_value(&self) -> &'r CoreValue {
40 self.0
41 }
42}
43
44impl ValueRef<'_> for D1ValueRef<'_> {
45 type Database = D1;
46
47 fn to_owned(&self) -> D1Value {
48 D1Value(self.0.clone())
49 }
50
51 fn type_info(&self) -> Cow<'_, D1TypeInfo> {
52 Cow::Owned(self.0.type_info())
53 }
54
55 fn is_null(&self) -> bool {
56 self.0.is_null()
57 }
58}