frontmatter_gen::engine

Struct Engine

Source
pub struct Engine { /* private fields */ }
Expand description

The primary engine responsible for site generation.

Handles the loading of templates, processing of content files, rendering of pages, and copying of static assets.

Implementations§

Source§

impl Engine

Source

pub fn new() -> Result<Self>

Creates a new Engine instance.

§Errors

Returns an error if initializing the internal state fails, which is unlikely in this implementation.

Source

pub async fn generate(&self, config: &Config) -> Result<()>

Orchestrates the complete site generation process.

§Errors

Returns an error if:

  • The output directory cannot be created.
  • Templates fail to load.
  • Content files fail to process.
  • Pages fail to generate.
  • Assets fail to copy.
Source

pub async fn load_templates(&self, config: &Config) -> Result<()>

Loads and caches all templates from the template directory.

§Errors

Returns an error if:

  • Template files cannot be read or parsed.
  • Directory entries fail to load.
  • File paths contain invalid characters.
Source

pub async fn process_content_files(&self, config: &Config) -> Result<()>

Processes all content files in the content directory.

§Errors

This function will return an error if:

  • The content directory cannot be read.
  • Any content file fails to process.
  • Writing to the cache encounters an issue.
Source

pub async fn process_content_file( &self, path: &Path, config: &Config, ) -> Result<ContentFile>

Processes a single content file and prepares it for rendering.

§Errors

This function will return an error if:

  • The content file cannot be read.
  • The front matter extraction fails.
  • The Markdown to HTML conversion encounters an issue.
  • The destination path is invalid.
Source

pub fn extract_front_matter( &self, content: &str, ) -> Result<(HashMap<String, Value>, String)>

Extracts frontmatter metadata and content body from a file.

§Errors

This function will return an error if:

  • The front matter is not valid YAML.
  • The content cannot be split correctly into metadata and body.
Source

pub fn render_template( &self, template: &str, content: &ContentFile, ) -> Result<String>

Renders a template with the provided content.

§Errors

This function will return an error if:

  • The template contains invalid syntax.
  • The rendering process fails due to missing or invalid context variables.
Source

pub async fn copy_assets(&self, config: &Config) -> Result<()>

Copies static assets from the content directory to the output directory.

§Errors

This function will return an error if:

  • The assets directory does not exist or cannot be read.
  • A file or directory cannot be copied to the output directory.
  • An I/O error occurs during the copying process.
Source

pub async fn generate_pages(&self, _config: &Config) -> Result<()>

Generates HTML pages from processed content files.

§Errors

This function will return an error if:

  • Reading from the content cache fails.
  • A page cannot be generated or written to the output directory.

Trait Implementations§

Source§

impl Debug for Engine

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl !UnwindSafe for Engine

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> 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T