surrealdb_sql/
fetch.rs

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