pub mod auth;
pub mod csv;
pub mod dump;
pub mod format;
pub mod json;
pub mod lines;
pub mod progress;
pub mod prose;
pub(crate) mod table;
#[cfg(test)]
mod test_support;
pub mod tsv;
pub(crate) mod value;
pub(crate) mod vocabulary;
pub use auth::{AuthLoginOutcome, AuthLogoutOutcome, AuthSetTokenOutcome, AuthStatusOutcome};
pub use dump::{DumpDeleteOutcome, DumpEvent, DumpOutcome};
pub use format::Format;
pub use progress::{HumanProgress, JsonProgress, ProgressReporter};
pub(crate) use table::{
AUTH_LOGIN_COLUMNS, AUTH_LOGOUT_COLUMNS, DATA_MODEL_DESCRIBE_COLUMNS, DATA_MODEL_STRUCTURE_COLUMNS,
DATA_MODELS_COLUMNS, PROJECT_DUMP_COLUMNS, PROJECT_DUMP_DELETED_COLUMNS, PROJECTS_COLUMNS, QuoteMode,
RESOURCE_DESCRIBE_COLUMNS, RESOURCE_DESCRIBE_VALUES_COLUMNS, RESOURCE_DESCRIBE_VALUES_DEFAULT_COLUMNS,
RESOURCE_LIST_COLUMNS, RESOURCE_TYPE_DESCRIBE_COLUMNS, RESOURCE_TYPE_DESCRIBE_DEFAULT_COLUMNS,
RESOURCE_TYPES_COLUMNS, RESOURCE_TYPES_DEFAULT_COLUMNS, TableSpec, VOCABULARIES_COLUMNS,
VOCABULARIES_COUNTED_DEFAULT_COLUMNS, VOCABULARIES_DEFAULT_COLUMNS, VOCABULARY_DESCRIBE_COLUMNS,
VOCABULARY_DESCRIBE_DEFAULT_COLUMNS, render_table,
};
pub use table::{HeaderMode, TableOptions};
use crate::diagnostic::Diagnostic;
use crate::model::{
DataModel, DataModelDetail, DataModelStructure, Project, ProjectDetail, ResourceDetail, ResourceSummary,
ResourceType, ResourceTypeDetail, Vocabulary, VocabularyDetail,
};
#[derive(Debug)]
pub struct ProjectListView {
pub items: Vec<Project>,
pub total: usize,
pub filter: Option<String>,
}
#[derive(Debug, Clone)]
pub struct DataModelListView {
pub items: Vec<DataModel>,
pub total: usize,
pub filter: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ResourceTypeListView {
pub items: Vec<ResourceType>,
pub total: usize,
pub filter: Option<String>,
pub data_model: String,
}
#[derive(Debug, Clone)]
pub enum ResourceListPagination {
SinglePage {
page: u32,
may_have_more: bool,
},
AllPages {
pages_fetched: u32,
},
}
#[derive(Debug, Clone)]
pub struct ResourceListView {
pub items: Vec<ResourceSummary>,
pub total: usize,
pub filter: Option<String>,
pub resource_type: String,
pub pagination: ResourceListPagination,
}
#[derive(Debug, Clone)]
pub struct VocabularyListView {
pub items: Vec<Vocabulary>,
pub total: usize,
pub filter: Option<String>,
pub counted: bool,
}
#[derive(Debug, Clone)]
pub struct MetaContext {
pub server_label: String,
pub auth_state: String,
pub filter_warning: Option<String>,
pub count_caveat: Option<String>,
pub count_cost: Option<String>,
}
pub trait Renderer {
fn diagnostic(&mut self, diag: &Diagnostic, meta: &MetaContext) -> Result<(), Diagnostic>;
fn auth_login(&mut self, outcome: &AuthLoginOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn auth_status(&mut self, outcome: &AuthStatusOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn auth_logout(&mut self, outcome: &AuthLogoutOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn auth_set_token(&mut self, outcome: &AuthSetTokenOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn project_dump(&mut self, outcome: &DumpOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn project_dump_deleted(&mut self, outcome: &DumpDeleteOutcome, meta: &MetaContext) -> Result<(), Diagnostic>;
fn projects(&mut self, view: &ProjectListView, meta: &MetaContext) -> Result<(), Diagnostic>;
fn project_describe(&mut self, project: &ProjectDetail, meta: &MetaContext) -> Result<(), Diagnostic>;
fn data_models(&mut self, view: &DataModelListView, meta: &MetaContext) -> Result<(), Diagnostic>;
fn data_model_describe(&mut self, detail: &DataModelDetail, meta: &MetaContext) -> Result<(), Diagnostic>;
fn resource_types(&mut self, view: &ResourceTypeListView, meta: &MetaContext) -> Result<(), Diagnostic>;
fn resource_type_describe(&mut self, detail: &ResourceTypeDetail, meta: &MetaContext) -> Result<(), Diagnostic>;
fn data_model_structure(&mut self, structure: &DataModelStructure, meta: &MetaContext) -> Result<(), Diagnostic>;
fn resources(&mut self, view: &ResourceListView, meta: &MetaContext) -> Result<(), Diagnostic>;
fn resource_describe(&mut self, detail: &ResourceDetail, meta: &MetaContext) -> Result<(), Diagnostic>;
fn vocabularies(&mut self, view: &VocabularyListView, meta: &MetaContext) -> Result<(), Diagnostic>;
fn vocabulary_describe(&mut self, detail: &VocabularyDetail, meta: &MetaContext) -> Result<(), Diagnostic>;
}