Skip to main content

EngineDocument

Struct EngineDocument 

Source
pub struct EngineDocument {
    pub address: String,
    pub title: Option<String>,
    pub content_type: String,
    pub lang: Option<String>,
    pub provenance: DocumentProvenance,
    pub trust: DocumentTrustState,
    pub diagnostics: Vec<DocumentDiagnostic>,
    pub blocks: Vec<Block>,
}
Expand description

A rendered document.

Portable, serializable, host-neutral. No layout coordinates — those come later in platen once a real surface and font system are bound.

A11y note: the document maps to an AccessKit Role::Document node. title is the document’s accessible name; lang is its declared language (BCP 47). Engines that don’t see a language declaration leave lang as None and the host fills it from environment defaults.

Fields§

§address: String

The address the engine was asked to render. May differ from provenance.canonical_uri when the host followed a redirect.

§title: Option<String>§content_type: String§lang: Option<String>

BCP 47 language tag (e.g. "en", "en-GB", "ja"). None when the engine had no signal — host supplies a default during projection.

§provenance: DocumentProvenance

Where the document came from. Defaulted to Default on engines that haven’t been updated yet; new engines should populate at least source_kind and canonical_uri.

§trust: DocumentTrustState

How authenticated the source is. Default is Unknown; the host or the engine fills it in once enough information is available.

§diagnostics: Vec<DocumentDiagnostic>

Parser / render warnings worth surfacing to the user or to a debug overlay. Defaults to empty.

§blocks: Vec<Block>

Implementations§

Source§

impl EngineDocument

Source

pub fn to_gophermap(&self, ctx: &GophermapContext) -> String

Render the document as a gophermap (RFC 1436 menu). See the module docs for the downgrade rules.

Source

pub fn to_text(&self) -> String

Render the document as plain text. See the module docs for the flattening rules.

Source§

impl EngineDocument

Source

pub fn to_html(&self) -> String

Render the document as an HTML body fragment. See the module docs for the mapping rules.

Source§

impl EngineDocument

Source

pub fn to_markdown(&self) -> String

Render the document as CommonMark.

Source

pub fn to_gemini(&self) -> String

Render the document as gemtext (text/gemini).

Spec-faithful: emphasis / strong / inline code styling is flattened to plain text since gemtext has no inline styling. Inline Link spans inside paragraphs are emitted as separate => url label lines after the paragraph, matching gemtext’s link-line model.

Source

pub fn to_knot(&self) -> String

Render the document as a knot file (frontmatter + body).

Frontmatter is written when the document has any of: a title, provenance.canonical_uri / fetched_at / source_label, or a non-Unknown trust state. The body is the same shape as to_markdown() for structural blocks, with semantic variants (FeedHeader, FeedEntry, MetadataRow, Badge) rendered as fenced code blocks with their protocol language tag — so they round-trip through nematic::KnotEngine’s polyglot fence expansion without losing semantic intent.

Round-trip: parse → to_knot → parse → equivalent document for the document-level metadata + every structural and semantic block. note_kind and tags MetadataRow blocks are NOT re-extracted to frontmatter on re-render — they stay as MetadataRow blocks in the body, preserving their content but shifting their storage location. (Asymmetry by design; the reverse-extraction would be fragile against user-authored MetadataRows that happen to use kind / tags labels.)

Source

pub fn write_knot_body(&self, out: &mut String)

Append the knot body (blocks only — no frontmatter) to out.

Companion to Self::to_knot for callers that emit their own frontmatter and just want the rendered block stream. Used by nematic::knot::build_clip_knot so the clip-aware frontmatter (which carries note_kind and other knot-format extensions outside EngineDocument’s shape) isn’t doubled by the document-level frontmatter to_knot would otherwise emit.

Source§

impl EngineDocument

Source

pub fn walk_inline_spans(&self) -> Vec<&InlineSpan>

Walk every block (and nested blocks inside quotes / list items), yielding inline spans in document order. Useful for link extraction and plain-text summarisation.

Extract every link target referenced by the document, in document order. Walks both inline Link spans inside structural blocks and the URL fields of semantic blocks (FeedHeader.source_url, FeedEntry.article_url / source_url).

Trait Implementations§

Source§

impl Clone for EngineDocument

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EngineDocument

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EngineDocument

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EngineDocument

Source§

impl PartialEq for EngineDocument

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for EngineDocument

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for EngineDocument

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more