cursive_tree/view/
state.rs1use super::{
2 super::{backend::*, model::*},
3 tree::*,
4};
5
6use cursive::event::*;
7
8impl<BackendT, ContextT, ErrorT, IdT, DataT> TreeView<BackendT, ContextT, ErrorT, IdT, DataT> {
9 pub fn toggle_branch_state(
11 node: &mut Node<BackendT, ContextT, ErrorT, IdT, DataT>,
12 context: ContextT,
13 ) -> EventResult
14 where
15 BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
16 ContextT: Clone,
17 ErrorT: 'static + Send + Sync,
18 {
19 EventResult::Consumed(match node.toggle_branch_state(context) {
20 Ok(_) => None,
21 Err(error) => Some(Callback::from_fn_once(|cursive| {
22 BackendT::handle_error(cursive, error);
23 })),
24 })
25 }
26
27 pub fn expand_branch(node: &mut Node<BackendT, ContextT, ErrorT, IdT, DataT>, context: ContextT) -> EventResult
29 where
30 BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
31 ContextT: Clone,
32 ErrorT: 'static + Send + Sync,
33 {
34 EventResult::Consumed(match node.expand_branch(context) {
35 Ok(_) => None,
36 Err(error) => Some(Callback::from_fn_once(|cursive| {
37 BackendT::handle_error(cursive, error);
38 })),
39 })
40 }
41}