pub struct Search<'a> { /* private fields */ }

Implementations§

Examples found in repository?
src/lib.rs (line 522)
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
    pub fn begin_search(&self) -> Search {
        Search::new(self)
    }
    pub fn search_field(&self, field_name: impl Into<String>, condition: search::Field) -> Search {
        Search::new(self).search_field(field_name, condition)
    }
    pub fn search_activity(&self, condition: Activity) -> Search {
        Search::new(self).search_activity(condition)
    }
    pub fn search_term(&self, condition: search::Term) -> Search {
        Search::new(self).search_term(condition)
    }
    pub fn search_row(&self, condition: search::Number) -> Search {
        Search::new(self).search_row(condition)
    }
    pub fn search_default(&self) -> Search {
        Search::new(self).search_default()
    }
More examples
Hide additional examples
src/search.rs (line 59)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
        match condition {
            Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
            Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
            Condition::Field(field_name, condition) => {
                Self::search_exec_field(data, field_name, condition, tx)
            }
            Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
            Condition::LastUpdated(condition) => {
                Self::search_exec_last_updated(data, condition, tx)
            }
            Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
            Condition::Narrow(conditions) => {
                let mut new_search = Search::new(data);
                for c in conditions {
                    new_search = new_search.search(c.clone());
                }
                tx.send(new_search.result()).unwrap();
            }
            Condition::Wide(conditions) => {
                let (tx_inner, rx) = std::sync::mpsc::channel();
                for c in conditions {
                    let tx_inner = tx_inner.clone();
                    Self::search_exec_cond(data, c, tx_inner);
                }
                drop(tx_inner);
                std::thread::spawn(move || {
                    let mut tmp = RowSet::default();
                    for ref mut rs in rx {
                        tmp.append(rs);
                    }
                    tx.send(tmp).unwrap();
                });
            }
        };
    }
Examples found in repository?
src/lib.rs (line 537)
536
537
538
    pub fn search_default(&self) -> Search {
        Search::new(self).search_default()
    }
Examples found in repository?
src/lib.rs (line 525)
524
525
526
    pub fn search_field(&self, field_name: impl Into<String>, condition: search::Field) -> Search {
        Search::new(self).search_field(field_name, condition)
    }
Examples found in repository?
src/lib.rs (line 531)
530
531
532
    pub fn search_term(&self, condition: search::Term) -> Search {
        Search::new(self).search_term(condition)
    }
Examples found in repository?
src/lib.rs (line 528)
527
528
529
    pub fn search_activity(&self, condition: Activity) -> Search {
        Search::new(self).search_activity(condition)
    }
Examples found in repository?
src/lib.rs (line 534)
533
534
535
    pub fn search_row(&self, condition: search::Number) -> Search {
        Search::new(self).search_row(condition)
    }
Examples found in repository?
src/search.rs (line 29)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
    pub fn search_field(self, field_name: impl Into<String>, condition: Field) -> Self {
        self.search(Condition::Field(field_name.into(), condition))
    }
    pub fn search_term(self, condition: Term) -> Self {
        self.search(Condition::Term(condition))
    }
    pub fn search_activity(self, condition: Activity) -> Self {
        self.search(Condition::Activity(condition))
    }
    pub fn search_row(self, condition: Number) -> Self {
        self.search(Condition::Row(condition))
    }

    pub fn search(mut self, condition: Condition) -> Self {
        self.conditions.push(condition);
        self
    }

    pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
        match condition {
            Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
            Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
            Condition::Field(field_name, condition) => {
                Self::search_exec_field(data, field_name, condition, tx)
            }
            Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
            Condition::LastUpdated(condition) => {
                Self::search_exec_last_updated(data, condition, tx)
            }
            Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
            Condition::Narrow(conditions) => {
                let mut new_search = Search::new(data);
                for c in conditions {
                    new_search = new_search.search(c.clone());
                }
                tx.send(new_search.result()).unwrap();
            }
            Condition::Wide(conditions) => {
                let (tx_inner, rx) = std::sync::mpsc::channel();
                for c in conditions {
                    let tx_inner = tx_inner.clone();
                    Self::search_exec_cond(data, c, tx_inner);
                }
                drop(tx_inner);
                std::thread::spawn(move || {
                    let mut tmp = RowSet::default();
                    for ref mut rs in rx {
                        tmp.append(rs);
                    }
                    tx.send(tmp).unwrap();
                });
            }
        };
    }
Examples found in repository?
src/search.rs (line 69)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
    pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
        match condition {
            Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
            Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
            Condition::Field(field_name, condition) => {
                Self::search_exec_field(data, field_name, condition, tx)
            }
            Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
            Condition::LastUpdated(condition) => {
                Self::search_exec_last_updated(data, condition, tx)
            }
            Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
            Condition::Narrow(conditions) => {
                let mut new_search = Search::new(data);
                for c in conditions {
                    new_search = new_search.search(c.clone());
                }
                tx.send(new_search.result()).unwrap();
            }
            Condition::Wide(conditions) => {
                let (tx_inner, rx) = std::sync::mpsc::channel();
                for c in conditions {
                    let tx_inner = tx_inner.clone();
                    Self::search_exec_cond(data, c, tx_inner);
                }
                drop(tx_inner);
                std::thread::spawn(move || {
                    let mut tmp = RowSet::default();
                    for ref mut rs in rx {
                        tmp.append(rs);
                    }
                    tx.send(tmp).unwrap();
                });
            }
        };
    }
    fn search_exec(&mut self) -> RowSet {
        let mut rows = RowSet::default();
        if self.conditions.len() > 0 {
            let (tx, rx) = std::sync::mpsc::channel();
            for c in &self.conditions {
                let tx = tx.clone();
                Self::search_exec_cond(self.data, c, tx);
            }
            drop(tx);
            let mut fst = true;
            for rs in rx {
                if fst {
                    rows = rs;
                    fst = false;
                } else {
                    rows = rows.intersection(&rs).map(|&x| x).collect()
                }
            }
        } else {
            for row in self.data.serial.read().unwrap().index().triee().iter() {
                rows.insert(row.row());
            }
        }
        rows
    }
Examples found in repository?
src/search.rs (line 63)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
        match condition {
            Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
            Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
            Condition::Field(field_name, condition) => {
                Self::search_exec_field(data, field_name, condition, tx)
            }
            Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
            Condition::LastUpdated(condition) => {
                Self::search_exec_last_updated(data, condition, tx)
            }
            Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
            Condition::Narrow(conditions) => {
                let mut new_search = Search::new(data);
                for c in conditions {
                    new_search = new_search.search(c.clone());
                }
                tx.send(new_search.result()).unwrap();
            }
            Condition::Wide(conditions) => {
                let (tx_inner, rx) = std::sync::mpsc::channel();
                for c in conditions {
                    let tx_inner = tx_inner.clone();
                    Self::search_exec_cond(data, c, tx_inner);
                }
                drop(tx_inner);
                std::thread::spawn(move || {
                    let mut tmp = RowSet::default();
                    for ref mut rs in rx {
                        tmp.append(rs);
                    }
                    tx.send(tmp).unwrap();
                });
            }
        };
    }
Examples found in repository?
src/search.rs (line 57)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
    pub fn search_exec_cond(data: &Data, condition: &Condition, tx: Sender<RowSet>) {
        match condition {
            Condition::Activity(condition) => Self::search_exec_activity(data, condition, tx),
            Condition::Term(condition) => Self::search_exec_term(data, condition, tx),
            Condition::Field(field_name, condition) => {
                Self::search_exec_field(data, field_name, condition, tx)
            }
            Condition::Row(condition) => Self::search_exec_row(data, condition, tx),
            Condition::LastUpdated(condition) => {
                Self::search_exec_last_updated(data, condition, tx)
            }
            Condition::Uuid(uuid) => Self::search_exec_uuid(data, uuid, tx),
            Condition::Narrow(conditions) => {
                let mut new_search = Search::new(data);
                for c in conditions {
                    new_search = new_search.search(c.clone());
                }
                tx.send(new_search.result()).unwrap();
            }
            Condition::Wide(conditions) => {
                let (tx_inner, rx) = std::sync::mpsc::channel();
                for c in conditions {
                    let tx_inner = tx_inner.clone();
                    Self::search_exec_cond(data, c, tx_inner);
                }
                drop(tx_inner);
                std::thread::spawn(move || {
                    let mut tmp = RowSet::default();
                    for ref mut rs in rx {
                        tmp.append(rs);
                    }
                    tx.send(tmp).unwrap();
                });
            }
        };
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.