#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub mod json;
#[cfg(feature = "yaml")]
#[cfg_attr(docsrs, doc(cfg(feature = "yaml")))]
pub mod yaml;
#[cfg(feature = "tree")]
#[cfg_attr(docsrs, doc(cfg(feature = "tree")))]
pub mod tree;
#[derive(Clone, Debug, PartialEq)]
pub enum ContainerType {
Object,
Array,
}
impl ContainerType {
pub fn open_str(&self) -> &'static str {
match self {
ContainerType::Object => "{",
ContainerType::Array => "[",
}
}
pub fn close_str(&self) -> &'static str {
match self {
ContainerType::Object => "}",
ContainerType::Array => "]",
}
}
pub fn empty_str(&self) -> &'static str {
match self {
ContainerType::Object => "{}",
ContainerType::Array => "[]",
}
}
pub fn collapsed_preview(&self) -> &'static str {
match self {
ContainerType::Object => "{…}",
ContainerType::Array => "[…]",
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum ContainerNode {
Empty { typ: ContainerType },
Open {
typ: ContainerType,
collapsed: bool,
close_index: usize,
},
Close {
typ: ContainerType,
collapsed: bool,
open_index: usize,
},
}
pub trait PrettyRender {
fn render_pretty(&self, indent: usize) -> String;
}
pub trait RowOperation {
type Row;
fn up(&self, current: usize) -> usize;
fn head(&self) -> usize;
fn down(&self, current: usize) -> usize;
fn tail(&self) -> usize;
fn toggle(&mut self, current: usize) -> usize;
fn set_rows_visibility(&mut self, collapsed: bool);
fn extract(&self, current: usize, n: usize) -> Vec<Self::Row>;
}