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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crate::{GValue, ToGValue};

#[derive(Debug, PartialEq, Clone)]
pub struct TextP {
    pub(crate) operator: String,
    pub(crate) value: Box<GValue>,
}

impl TextP {
    pub fn operator(&self) -> &String {
        &self.operator
    }

    pub fn value(&self) -> &GValue {
        &self.value
    }

    pub(crate) fn new<T>(operator: T, value: GValue) -> TextP
    where
        T: Into<String>,
    {
        TextP {
            operator: operator.into(),
            value: Box::new(value),
        }
    }
    pub fn containing<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("containing", value.to_gvalue())
    }

    pub fn starting_with<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("startingWith", value.to_gvalue())
    }

    pub fn ending_with<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("endingWith", value.to_gvalue())
    }

    pub fn not_starting_with<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("notStartingWith", value.to_gvalue())
    }

    pub fn not_ending_with<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("notEndingWith", value.to_gvalue())
    }

    pub fn not_containing<V>(value: V) -> TextP
    where
        V: ToGValue,
    {
        TextP::new("notContaining", value.to_gvalue())
    }
}