surrealdb_expr/expr/
split.rs1use std::ops::Deref;
2
3use surrealdb_types::{SqlFormat, ToSql};
4
5use crate::expr::idiom::Idiom;
6
7#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
8pub struct Splits(pub Vec<Split>);
9
10impl Splits {
11 pub fn read_only(&self) -> bool {
14 self.0.iter().all(|x| x.read_only())
15 }
16}
17
18impl Deref for Splits {
19 type Target = Vec<Split>;
20 fn deref(&self) -> &Self::Target {
21 &self.0
22 }
23}
24
25impl IntoIterator for Splits {
26 type Item = Split;
27 type IntoIter = std::vec::IntoIter<Self::Item>;
28 fn into_iter(self) -> Self::IntoIter {
29 self.0.into_iter()
30 }
31}
32
33impl ToSql for Splits {
34 fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
35 let sql_splits: crate::sql::Splits = self.clone().into();
36 sql_splits.fmt_sql(f, fmt);
37 }
38}
39
40#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
41pub struct Split(pub Idiom);
42
43impl Split {
44 pub fn read_only(&self) -> bool {
47 self.0.read_only()
48 }
49}
50
51impl Deref for Split {
52 type Target = Idiom;
53 fn deref(&self) -> &Self::Target {
54 &self.0
55 }
56}
57
58impl surrealdb_types::ToSql for Split {
59 fn fmt_sql(&self, f: &mut String, fmt: surrealdb_types::SqlFormat) {
60 let sql_split: crate::sql::Split = self.clone().into();
61 sql_split.fmt_sql(f, fmt);
62 }
63}