mod blueprint;
mod compose;
mod config;
mod fill;
mod formats;
mod ignore;
mod load;
mod query;
mod schema;
mod schema_yaml;
mod seed;
mod tree;
mod types;
pub(crate) mod validation;
pub use config::{CoercionError, QuillConfig};
pub(crate) use config::Leniency;
pub use fill::zero_value;
pub use formats::{parse_date, parse_datetime};
pub use ignore::QuillIgnore;
pub use schema::{build_transform_schema, QUILLMARK_INLINE_KEY, CONTENT_MEDIA_TYPE};
pub use tree::FileTreeNode;
pub use types::{
BodyCardSchema, CardSchema, FieldSchema, FieldType, GroupRegistry, GroupSchema, UiCardSchema,
UiFieldSchema,
};
use std::collections::HashMap;
use crate::value::QuillValue;
pub const STANDARD_METADATA_KEYS: &[&str] =
&["name", "backend", "description", "version", "author"];
#[derive(Clone)]
pub struct Quill {
pub(crate) metadata: HashMap<String, QuillValue>,
pub(crate) config: QuillConfig,
pub(crate) files: FileTreeNode,
}
impl Quill {
pub fn name(&self) -> &str {
&self.config.name
}
pub fn backend_id(&self) -> &str {
&self.config.backend
}
pub fn metadata(&self) -> &HashMap<String, QuillValue> {
&self.metadata
}
pub fn config(&self) -> &QuillConfig {
&self.config
}
pub fn writer<'a>(&'a self, doc: &'a mut crate::document::Document) -> crate::TypedWriter<'a> {
crate::TypedWriter::new(&self.config, doc)
}
pub fn view<'a>(&'a self, doc: &'a crate::document::Document) -> crate::TypedReader<'a> {
crate::TypedReader::new(&self.config, doc)
}
pub fn files(&self) -> &FileTreeNode {
&self.files
}
pub fn to_tree(&self) -> Vec<(String, Vec<u8>)> {
self.files.flatten()
}
}
impl std::fmt::Debug for Quill {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Quill")
.field("name", &self.config.name)
.field("backend_id", &self.config.backend)
.field("files", &"<FileTreeNode>")
.finish()
}
}
#[cfg(test)]
mod tests;