use super::super::{model::*, view::*};
use cursive::*;
pub const DEFAULT_LEAF_SYMBOL: &str = "▪";
pub const DEFAULT_BRANCH_EXPANDED_SYMBOL: &str = "▼";
pub const DEFAULT_BRANCH_COLLAPSED_SYMBOL: &str = "▶";
pub trait TreeBackend: Sized {
type Context;
type Error;
type ID;
type Data;
fn tree_view(context: Self::Context) -> TreeView<Self> {
Self::tree_model(context).into()
}
fn tree_model(context: Self::Context) -> TreeModel<Self> {
TreeModel::new(context)
}
#[allow(unused)]
fn symbol(node: &Node<Self>, context: Self::Context) -> Symbol<'_> {
match (node.kind, node.branch_state) {
(NodeKind::Leaf, _) => DEFAULT_LEAF_SYMBOL,
(NodeKind::Branch, BranchState::Expanded) => DEFAULT_BRANCH_EXPANDED_SYMBOL,
(NodeKind::Branch, BranchState::Collapsed) => DEFAULT_BRANCH_COLLAPSED_SYMBOL,
}
.into()
}
#[allow(unused)]
fn roots(context: Self::Context) -> Result<NodeList<Self>, Self::Error> {
Ok(Default::default())
}
#[allow(unused)]
fn populate(node: &mut Node<Self>, context: Self::Context) -> Result<(), Self::Error> {
Ok(())
}
#[allow(unused)]
fn data(node: &mut Node<Self>, context: Self::Context) -> Result<Option<(Self::Data, bool)>, Self::Error> {
Ok(None)
}
#[allow(unused)]
fn handle_selection_changed(cursive: &mut Cursive, context: Self::Context) {}
#[allow(unused)]
fn handle_error(cursive: &mut Cursive, context: Self::Context, error: Self::Error) {}
}