surrealdb_core/sql/
split.rs1use crate::sql::fmt::Fmt;
2use crate::sql::idiom::Idiom;
3use revision::revisioned;
4use serde::{Deserialize, Serialize};
5use std::fmt::{self, Display, Formatter};
6use std::ops::Deref;
7
8#[revisioned(revision = 1)]
9#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
10#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
11#[non_exhaustive]
12pub struct Splits(pub Vec<Split>);
13
14impl Deref for Splits {
15 type Target = Vec<Split>;
16 fn deref(&self) -> &Self::Target {
17 &self.0
18 }
19}
20
21impl IntoIterator for Splits {
22 type Item = Split;
23 type IntoIter = std::vec::IntoIter<Self::Item>;
24 fn into_iter(self) -> Self::IntoIter {
25 self.0.into_iter()
26 }
27}
28
29impl fmt::Display for Splits {
30 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31 write!(f, "SPLIT ON {}", Fmt::comma_separated(&self.0))
32 }
33}
34
35#[revisioned(revision = 1)]
36#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
37#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
38#[non_exhaustive]
39pub struct Split(pub Idiom);
40
41impl Deref for Split {
42 type Target = Idiom;
43 fn deref(&self) -> &Self::Target {
44 &self.0
45 }
46}
47
48impl Display for Split {
49 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
50 Display::fmt(&self.0, f)
51 }
52}