surrealdb_extra/query/parsing/
fetch.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use surrealdb::sql::{Fetch, Idiom, Value};
use crate::query::parsing::idiom::ExtraIdiom;

#[derive(Debug, Clone)]
pub struct ExtraFetch(pub Fetch);

impl From<Fetch> for ExtraFetch {
    fn from(value: Fetch) -> Self {
        Self(value)
    }
}

impl From<&str> for ExtraFetch {
    fn from(value: &str) -> Self {
        let idiom = ExtraIdiom::from(value).0;

        let mut fetch = Fetch::default();
        fetch.0 = Value::Idiom(idiom);

        Self(fetch)
    }
}

impl From<String> for ExtraFetch {
    fn from(value: String) -> Self {
        let idiom = ExtraIdiom::from(value).0;

        let mut fetch = Fetch::default();
        fetch.0 = Value::Idiom(idiom);

        Self(fetch)
    }
}

impl From<Idiom> for ExtraFetch {
    fn from(value: Idiom) -> Self {
        let mut fetch = Fetch::default();
        fetch.0 = Value::Idiom(value);

        Self(fetch)
    }
}

impl From<Value> for ExtraFetch {
    fn from(value: Value) -> Self {
        Self(value.into())
    }
}