Skip to main content

Engine

Struct Engine 

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

Tera-backed Markdown rendering engine for the nils-cli workspace.

Engine is constructed via Engine::builder so the determinism posture (no auto-escape, no now()) is enforced in one place. Templates are registered as raw (name, body) pairs, which lets consumer crates ship .md.tera assets through include_str! without filesystem lookups at runtime.

Implementations§

Source§

impl Engine

Source

pub fn builder() -> EngineBuilder

Returns an EngineBuilder configured for deterministic rendering. Always start engines from Engine::builder()Engine has no public constructor besides this builder.

Source

pub fn register_template( &mut self, name: &str, body: &str, ) -> Result<(), RenderError>

Register a template body under name. The body is parsed eagerly so syntax errors surface at registration time rather than render time. The check for now() calls is the only content gate; everything else is delegated to Tera’s parser.

Source

pub fn render_value( &self, name: &str, view: &Value, ) -> Result<String, RenderError>

Render a registered template against an opaque serde_json::Value view. This is the entry point the md-render binary will use in Sprint 3.

Source

pub fn render<T: Serialize>( &self, name: &str, view: &T, ) -> Result<String, RenderError>

Render a registered template against a typed view struct. Consumers prepare a flat serde::Serialize view in Rust and hand it to this method; the engine performs the serde_json::to_value conversion and the Tera render in one step.

Source

pub fn render_str<T: Serialize>( &mut self, body: &str, view: &T, ) -> Result<String, RenderError>

Render a literal template body without persistently registering it. The body is checked for now() calls and then rendered with the engine’s registered helpers and the supplied view. This is the migration path for callers that today use Tera::render_str directly and treat every render as a fresh one-shot template.

Source

pub fn register_helper<F>(&mut self, name: &str, function: F)
where F: Function + 'static,

Attach a domain-specific Tera function under name. This is the consumer extension point for Task 1.4: nils-agent-runtime’s cli_ref / script / skill_ref / state_out helpers register here without nils-markdown knowing the consumer’s domain.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V