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: StringThe 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: DocumentProvenanceWhere 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: DocumentTrustStateHow 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
impl EngineDocument
Sourcepub fn to_gophermap(&self, ctx: &GophermapContext) -> String
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§impl EngineDocument
impl EngineDocument
Sourcepub fn to_markdown(&self) -> String
pub fn to_markdown(&self) -> String
Render the document as CommonMark.
Sourcepub fn to_gemini(&self) -> String
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.
Sourcepub fn to_knot(&self) -> String
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.)
Sourcepub fn write_knot_body(&self, out: &mut String)
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
impl EngineDocument
Sourcepub fn walk_inline_spans(&self) -> Vec<&InlineSpan>
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.
Sourcepub fn outgoing_links(&self) -> Vec<&str>
pub fn outgoing_links(&self) -> Vec<&str>
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
impl Clone for EngineDocument
Source§impl Debug for EngineDocument
impl Debug for EngineDocument
Source§impl<'de> Deserialize<'de> for EngineDocument
impl<'de> Deserialize<'de> for EngineDocument
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EngineDocument
Source§impl PartialEq for EngineDocument
impl PartialEq for EngineDocument
Source§impl Serialize for EngineDocument
impl Serialize for EngineDocument
impl StructuralPartialEq for EngineDocument
Auto Trait Implementations§
impl Freeze for EngineDocument
impl RefUnwindSafe for EngineDocument
impl Send for EngineDocument
impl Sync for EngineDocument
impl Unpin for EngineDocument
impl UnsafeUnpin for EngineDocument
impl UnwindSafe for EngineDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.