pub struct Selection {
pub bucket: Option<String>,
pub project: Option<String>,
}Expand description
What the user has clicked.
Fields§
§bucket: Option<String>A chart bucket label (2026-09-22, 2026-09, 14:00 …).
project: Option<String>A full tool:project key.
Implementations§
Source§impl Selection
impl Selection
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
Sourcepub fn toggle_bucket(&mut self, label: &str)
pub fn toggle_bucket(&mut self, label: &str)
Select label, or clear it when it is already selected.
Examples found in repository?
examples/soak.rs (line 55)
30fn main() {
31 let mut args = std::env::args().skip(1);
32 let rounds: usize = args.next().and_then(|n| n.parse().ok()).unwrap_or(100);
33 let window = match args.next().as_deref() {
34 Some("all") => Window::All,
35 _ => Window::Month,
36 };
37 let query = Query {
38 bucket: tokenburn_core::Bucket::Day,
39 window,
40 ..Query::default()
41 };
42
43 println!("round rows rss MB");
44 let mut first = 0.0;
45 for i in 0..rounds {
46 let collected = collect(ToolFilter::All, window.start(Local::now()));
47 let rows = collected.rows;
48 let _ = build_report(&rows, &query);
49 let _ = time_series(&rows, &query);
50 let _ = pie(&by_project(&rows), 8);
51 let all = drill(&rows, &query, &Selection::default());
52 // Click a bar and a slice, as a user would.
53 let mut sel = Selection::default();
54 if let Some(l) = all.series.labels.get(3) {
55 sel.toggle_bucket(l);
56 }
57 if let Some(k) = all.pie.slices.first().and_then(|s| s.key.clone()) {
58 sel.toggle_project(&k);
59 }
60 let _ = drill(&rows, &query, &sel);
61 if i == 0 || i % (rounds / 10).max(1) == 0 || i == rounds - 1 {
62 let rss = rss_mb();
63 if i == 0 {
64 first = rss;
65 }
66 println!("{i:>5} {:>6} {rss:>7.1}", rows.len());
67 }
68 }
69 println!("first round {first:.1} MB → last round {:.1} MB", rss_mb());
70}Sourcepub fn toggle_project(&mut self, key: &str)
pub fn toggle_project(&mut self, key: &str)
Select key, or clear it when it is already selected.
Examples found in repository?
examples/soak.rs (line 58)
30fn main() {
31 let mut args = std::env::args().skip(1);
32 let rounds: usize = args.next().and_then(|n| n.parse().ok()).unwrap_or(100);
33 let window = match args.next().as_deref() {
34 Some("all") => Window::All,
35 _ => Window::Month,
36 };
37 let query = Query {
38 bucket: tokenburn_core::Bucket::Day,
39 window,
40 ..Query::default()
41 };
42
43 println!("round rows rss MB");
44 let mut first = 0.0;
45 for i in 0..rounds {
46 let collected = collect(ToolFilter::All, window.start(Local::now()));
47 let rows = collected.rows;
48 let _ = build_report(&rows, &query);
49 let _ = time_series(&rows, &query);
50 let _ = pie(&by_project(&rows), 8);
51 let all = drill(&rows, &query, &Selection::default());
52 // Click a bar and a slice, as a user would.
53 let mut sel = Selection::default();
54 if let Some(l) = all.series.labels.get(3) {
55 sel.toggle_bucket(l);
56 }
57 if let Some(k) = all.pie.slices.first().and_then(|s| s.key.clone()) {
58 sel.toggle_project(&k);
59 }
60 let _ = drill(&rows, &query, &sel);
61 if i == 0 || i % (rounds / 10).max(1) == 0 || i == rounds - 1 {
62 let rss = rss_mb();
63 if i == 0 {
64 first = rss;
65 }
66 println!("{i:>5} {:>6} {rss:>7.1}", rows.len());
67 }
68 }
69 println!("first round {first:.1} MB → last round {:.1} MB", rss_mb());
70}Trait Implementations§
impl Eq for Selection
impl StructuralPartialEq for Selection
Auto Trait Implementations§
impl Freeze for Selection
impl RefUnwindSafe for Selection
impl Send for Selection
impl Sync for Selection
impl Unpin for Selection
impl UnsafeUnpin for Selection
impl UnwindSafe for Selection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more