Debian Codegraph @

src/widgets/process_table/query/and.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#;
2
3 use craterust-analyzer cargo bottom 0.14.9 crate/::{
4 collectionrust-analyzer cargo bottom 0.14.9 collection/::processesrust-analyzer cargo bottom 0.14.9 collection/processes/::ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#,
5 widgetsrust-analyzer cargo bottom 0.14.9 widgets/::queryrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/::{
6 COMPARISON_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/COMPARISON_LIST., Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#, Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#, QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#, QueryProcessorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor#, QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#, errorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/::QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#,
7 },
8 };
9
10 /// A node where both the left hand side or the right hand side are considered.
11 /// Note that the right hand side is optional, as that's how I implemented it a
12 /// long time ago.
13 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
14 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) struct Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# {
15 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs.: Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#,
16 // TODO: Maybe don't need to box rhs?
17 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#rhs.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#>>,
18 }
19
20 impl Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# {
21 pub(superrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/) fn checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And]check().(&self, process: &ProcessHarvestrust-analyzer cargo bottom 0.14.9 collection/processes/ProcessHarvest#, is_using_command: bool) -> bool {
22 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rhs) = &self.rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#rhs. {
23 self.lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs..checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/impl#[Prefix]check().(process, is_using_command) && rhs.checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/impl#[Prefix]check().(process, is_using_command)
24 } else {
25 self.lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs..checkrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/impl#[Prefix]check().(process, is_using_command)
26 }
27 }
28 }
29
30 impl QueryProcessorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryProcessor# for Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# {
31 fn processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And][QueryProcessor]process().(query: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, options: &QueryOptionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#) -> QueryResultrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryResult#<Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And][QueryProcessor]>
32 where
33 Selfrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/impl#[And][QueryProcessor]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
34 {
35 const AND_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/AND_LIST.: [&str; 2] = ["and", "&&"];
36
37 let mut lhs = Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/impl#[Prefix][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
38 let mut rhs: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#>> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
39
40 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(queue_top) = query.frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().() {
41 let current_lowercase = queue_top.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().();
42 if AND_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/AND_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&current_lowercase.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
43 query.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().();
44
45 rhs = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#::processrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/impl#[Prefix][QueryProcessor]process().(query, options)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().));
46
47 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_queue_top) = query.frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().() {
48 if AND_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/AND_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&next_queue_top.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
49 // Must merge LHS and RHS
50 lhs = Prefixrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#::Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/prefix/Prefix#Or#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(Orrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or# {
51 lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#lhs.: Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# { lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs., rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#rhs. },
52 rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/or/Or#rhs.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
53 }));
54 rhs = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
55 } else {
56 break;
57 }
58 } else {
59 break;
60 }
61 } else if COMPARISON_LISTrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/COMPARISON_LIST..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&current_lowercase.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) {
62 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(QueryErrorrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/QueryError#::newrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/error/impl#[QueryError]new().("Comparison not valid here"));
63 } else {
64 break;
65 }
66 }
67
68 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Andrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And# { lhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#lhs., rhsrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/and/And#rhs. })
69 }
70 }