surrealdb_expr/expr/convert/
lookup.rs1use crate::sql::lookup::*;
7
8impl From<Lookup> for crate::expr::Lookup {
9 fn from(v: Lookup) -> Self {
10 Self {
11 kind: v.kind.into(),
12 expr: v.expr.map(From::from),
13 only: v.only,
14 what: v.what.into_iter().map(From::from).collect(),
15 cond: v.cond.map(Into::into),
16 split: v.split.map(Into::into),
17 group: v.group.map(Into::into),
18 order: v.order.map(Into::into),
19 limit: v.limit.map(Into::into),
20 start: v.start.map(Into::into),
21 alias: v.alias.map(Into::into),
22 }
23 }
24}
25
26impl From<crate::expr::Lookup> for Lookup {
27 fn from(v: crate::expr::Lookup) -> Self {
28 Lookup {
29 kind: v.kind.into(),
30 expr: v.expr.map(Into::into),
31 only: v.only,
32 what: v.what.into_iter().map(From::from).collect(),
33 cond: v.cond.map(Into::into),
34 split: v.split.map(Into::into),
35 group: v.group.map(Into::into),
36 order: v.order.map(Into::into),
37 limit: v.limit.map(Into::into),
38 start: v.start.map(Into::into),
39 alias: v.alias.map(Into::into),
40 }
41 }
42}
43
44impl From<LookupKind> for crate::expr::lookup::LookupKind {
45 fn from(v: LookupKind) -> Self {
46 match v {
47 LookupKind::Graph(dir) => Self::Graph(dir.into()),
48 LookupKind::Reference => Self::Reference,
49 }
50 }
51}
52
53impl From<crate::expr::lookup::LookupKind> for LookupKind {
54 fn from(v: crate::expr::lookup::LookupKind) -> Self {
55 match v {
56 crate::expr::lookup::LookupKind::Graph(dir) => Self::Graph(dir.into()),
57 crate::expr::lookup::LookupKind::Reference => Self::Reference,
58 }
59 }
60}
61
62impl From<LookupSubject> for crate::expr::lookup::LookupSubject {
63 fn from(v: LookupSubject) -> Self {
64 match v {
65 LookupSubject::Table {
66 table,
67 referencing_field,
68 } => Self::Table {
69 table: table.into(),
70 referencing_field,
71 },
72 LookupSubject::Range {
73 table,
74 range,
75 referencing_field,
76 } => Self::Range {
77 table: table.into(),
78 range: range.into(),
79 referencing_field,
80 },
81 }
82 }
83}
84
85impl From<crate::expr::lookup::LookupSubject> for LookupSubject {
86 fn from(v: crate::expr::lookup::LookupSubject) -> Self {
87 match v {
88 crate::expr::lookup::LookupSubject::Table {
89 table,
90 referencing_field,
91 } => Self::Table {
92 table: table.into(),
93 referencing_field,
94 },
95 crate::expr::lookup::LookupSubject::Range {
96 table,
97 range,
98 referencing_field,
99 } => Self::Range {
100 table: table.into(),
101 range: range.into(),
102 referencing_field,
103 },
104 }
105 }
106}