pub struct Quill {
pub metadata: HashMap<String, QuillValue>,
pub name: String,
pub backend: String,
pub glue: Option<String>,
pub example: Option<String>,
pub schema: QuillValue,
pub defaults: HashMap<String, QuillValue>,
pub examples: HashMap<String, Vec<QuillValue>>,
pub files: FileTreeNode,
}Expand description
A quill template bundle.
Fields§
§metadata: HashMap<String, QuillValue>Quill-specific metadata
name: StringName of the quill
backend: StringBackend identifier (e.g., “typst”)
glue: Option<String>Glue template content (optional)
example: Option<String>Markdown template content (optional)
schema: QuillValueField JSON schema (single source of truth for schema and defaults)
defaults: HashMap<String, QuillValue>Cached default values extracted from schema (for performance)
examples: HashMap<String, Vec<QuillValue>>Cached example values extracted from schema (for performance)
files: FileTreeNodeIn-memory file system (tree structure)
Implementations§
Source§impl Quill
impl Quill
Sourcepub fn from_path<P: AsRef<Path>>(
path: P,
) -> Result<Self, Box<dyn StdError + Send + Sync>>
pub fn from_path<P: AsRef<Path>>( path: P, ) -> Result<Self, Box<dyn StdError + Send + Sync>>
Create a Quill from a directory path
Sourcepub fn from_tree(
root: FileTreeNode,
_default_name: Option<String>,
) -> Result<Self, Box<dyn StdError + Send + Sync>>
pub fn from_tree( root: FileTreeNode, _default_name: Option<String>, ) -> Result<Self, Box<dyn StdError + Send + Sync>>
Create a Quill from a tree structure
This is the authoritative method for creating a Quill from an in-memory file tree.
§Arguments
root- The root node of the file tree_default_name- Unused parameter kept for API compatibility (name always from Quill.toml)
§Errors
Returns an error if:
- Quill.toml is not found in the file tree
- Quill.toml is not valid UTF-8 or TOML
- The glue file specified in Quill.toml is not found or not valid UTF-8
- Validation fails
Sourcepub fn from_json(
json_str: &str,
) -> Result<Self, Box<dyn StdError + Send + Sync>>
pub fn from_json( json_str: &str, ) -> Result<Self, Box<dyn StdError + Send + Sync>>
Create a Quill from a JSON representation
Parses a JSON string into an in-memory file tree and validates it. The
precise JSON contract is documented in designs/QUILL_DESIGN.md.
The JSON format MUST have a root object with a files key. The optional
metadata key provides additional metadata that overrides defaults.
Sourcepub fn typst_packages(&self) -> Vec<String>
pub fn typst_packages(&self) -> Vec<String>
Get the list of typst packages to download, if specified in Quill.toml
Sourcepub fn extract_defaults(&self) -> &HashMap<String, QuillValue>
pub fn extract_defaults(&self) -> &HashMap<String, QuillValue>
Get default values from the cached schema defaults
Returns a reference to the pre-computed defaults HashMap that was extracted during Quill construction. This is more efficient than re-parsing the schema.
This is used by ParsedDocument::with_defaults() to apply default values
to missing fields.
Sourcepub fn extract_examples(&self) -> &HashMap<String, Vec<QuillValue>>
pub fn extract_examples(&self) -> &HashMap<String, Vec<QuillValue>>
Get example values from the cached schema examples
Returns a reference to the pre-computed examples HashMap that was extracted during Quill construction. This is more efficient than re-parsing the schema.
Sourcepub fn get_file<P: AsRef<Path>>(&self, path: P) -> Option<&[u8]>
pub fn get_file<P: AsRef<Path>>(&self, path: P) -> Option<&[u8]>
Get file contents by path (relative to quill root)
Sourcepub fn file_exists<P: AsRef<Path>>(&self, path: P) -> bool
pub fn file_exists<P: AsRef<Path>>(&self, path: P) -> bool
Check if a file exists in memory
Sourcepub fn dir_exists<P: AsRef<Path>>(&self, path: P) -> bool
pub fn dir_exists<P: AsRef<Path>>(&self, path: P) -> bool
Check if a directory exists in memory
Sourcepub fn list_files<P: AsRef<Path>>(&self, path: P) -> Vec<String>
pub fn list_files<P: AsRef<Path>>(&self, path: P) -> Vec<String>
List files in a directory (non-recursive, returns file names only)
Sourcepub fn list_subdirectories<P: AsRef<Path>>(&self, path: P) -> Vec<String>
pub fn list_subdirectories<P: AsRef<Path>>(&self, path: P) -> Vec<String>
List subdirectories in a directory (non-recursive, returns directory names only)
Sourcepub fn list_directory<P: AsRef<Path>>(&self, dir_path: P) -> Vec<PathBuf>
pub fn list_directory<P: AsRef<Path>>(&self, dir_path: P) -> Vec<PathBuf>
List all files in a directory (returns paths relative to quill root)