Quill

Struct Quill 

Source
pub struct Quill {
    pub glue_template: String,
    pub metadata: HashMap<String, Value>,
    pub base_path: PathBuf,
    pub name: String,
    pub glue_file: String,
    pub template_file: Option<String>,
    pub template: Option<String>,
    pub files: HashMap<PathBuf, FileEntry>,
}
Expand description

A quill template bundle. See module docs for examples.

Fields§

§glue_template: String

The template content

§metadata: HashMap<String, Value>

Quill-specific metadata

§base_path: PathBuf

Base path for resolving relative paths

§name: String

Name of the quill

§glue_file: String

Glue template file name

§template_file: Option<String>

Markdown template file name (optional)

§template: Option<String>

Markdown template content (optional)

§files: HashMap<PathBuf, FileEntry>

In-memory file system

Implementations§

Source§

impl Quill

Source

pub fn from_path<P: AsRef<Path>>( path: P, ) -> Result<Self, Box<dyn StdError + Send + Sync>>

Create a Quill from a directory path

Source

pub fn from_tree( files: HashMap<PathBuf, FileEntry>, base_path: Option<PathBuf>, default_name: Option<String>, ) -> Result<Self, Box<dyn StdError + Send + Sync>>

Create a Quill from a tree of files (authoritative method)

This is the authoritative method for creating a Quill from an in-memory file tree. Both from_path and from_json use this method internally.

§Arguments
  • files - A map of file paths to FileEntry objects representing the file tree
  • base_path - Optional base path for the Quill (defaults to “/”)
  • default_name - Optional default name (will be overridden by name in 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
Source

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 representing a Quill and creates a Quill instance. The JSON should have the following structure:

{
  "name": "optional-default-name",
  "base_path": "/optional/base/path",
  "files": {
    "Quill.toml": {
      "contents": "...",  // UTF-8 string or byte array
      "is_dir": false
    },
    "glue.typ": {
      "contents": "...",
      "is_dir": false
    }
  }
}

File contents can be either:

  • A UTF-8 string (recommended for text files)
  • An array of byte values (for binary files)
§Errors

Returns an error if:

  • The JSON is malformed
  • The “files” field is missing or not an object
  • Any file contents are invalid
  • Validation fails (via from_tree)
Source

pub fn toml_to_yaml_value( toml_val: &Value, ) -> Result<Value, Box<dyn StdError + Send + Sync>>

Convert TOML value to YAML value

Source

pub fn assets_path(&self) -> PathBuf

Get the path to the assets directory

Source

pub fn packages_path(&self) -> PathBuf

Get the path to the packages directory

Source

pub fn glue_path(&self) -> PathBuf

Get the path to the glue file

Source

pub fn typst_packages(&self) -> Vec<String>

Get the list of typst packages to download, if specified in Quill.toml

Source

pub fn validate(&self) -> Result<(), Box<dyn StdError + Send + Sync>>

Validate the quill structure

Source

pub fn get_file<P: AsRef<Path>>(&self, path: P) -> Option<&[u8]>

Get file contents by path (relative to quill root)

Source

pub fn get_file_entry<P: AsRef<Path>>(&self, path: P) -> Option<&FileEntry>

Get file entry by path (includes metadata)

Source

pub fn file_exists<P: AsRef<Path>>(&self, path: P) -> bool

Check if a file exists in memory

Source

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)

Source

pub fn list_subdirectories<P: AsRef<Path>>(&self, dir_path: P) -> Vec<PathBuf>

List all directories in a directory (returns paths relative to quill root)

Source

pub fn find_files<P: AsRef<Path>>(&self, pattern: P) -> Vec<PathBuf>

Get all files matching a pattern (supports simple wildcards)

Trait Implementations§

Source§

impl Clone for Quill

Source§

fn clone(&self) -> Quill

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Quill

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Quill

§

impl RefUnwindSafe for Quill

§

impl Send for Quill

§

impl Sync for Quill

§

impl Unpin for Quill

§

impl UnwindSafe for Quill

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DynFilter for T
where T: Send + Sync + 'static,