Skip to main content

TextModel

Struct TextModel 

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

A Quarb adapter over a text-level document.

Implementations§

Source§

impl TextModel

Source

pub fn build(blocks: Vec<Block>) -> Self

Assemble the document tree from a adapter’s event stream.

Iterative throughout (the stream is flat; prose flattening runs over indices), so pathological nesting cannot overflow the call stack. Lenient on malformed streams: a stray Close is ignored, unclosed containers close at the end.

Source

pub fn set_bib_aliases(&mut self, map: HashMap<String, String>)

Register the bib-field alias census (alias → canonical campus), lowercased keys — the friction remover: a field authored or queried under any covered name answers.

Source

pub fn set_document_url(&mut self, url: &str)

Declare the document’s own URL — the base a relative ref target joins against when --> reaches across documents.

Declare the base relative reference targets join against — html’s <base href> — when it differs from the document’s own URL.

Source

pub fn set_document_path(&mut self, path: &str)

Declare where the document is served from when it declares no absolute URL of its own: the base ::href links against (a mount path, an archive member’s path).

Source

pub fn set_head_meta(&mut self, head: HeadMeta)

Attach what the document declares about itself; the format adapter reads it from the source’s own metadata vocabulary.

Source

pub fn head_meta(&self) -> &HeadMeta

What the document declares about itself.

Source

pub fn plain_text(&self) -> String

The document’s text as one string: every section’s lemma and every block’s prose, one per line, in document order — the lowering a substrate stores beside the document so a substring predicate inside the graft can be prefiltered on it. The invariant a prefilter relies on: every grafted node’s prose (and every lemma) is a substring of this.

Source

pub fn node_count(&self) -> usize

How many nodes the document holds (the root included) — the bound a host needs to pack this document’s node ids into a wider id space.

Source

pub fn parse_plain(text: &str) -> Self

Read plain text: blank-line-separated paragraphs, each collapsed to one line — the atramento paragraph rule. No headings, no markup.

Source

pub fn locator(&self, node: NodeId) -> String

A locator path to node, like /section[2]/paragraph[3], for rendering. A [n] index is added only to disambiguate same-name siblings.

Trait Implementations§

Source§

impl AstAdapter for TextModel

Source§

fn traits(&self, node: NodeId) -> Vec<String>

The <block> family on every block node, plus <table> on a list that denormalizes a table. Kinds are node names, not traits.

Source§

fn property(&self, node: NodeId, name: &str) -> Option<Value>

::lemma (title), ::hypograph (footer or attribution), ::taxis (ordinal), ::text (the flattened prose, same as the bare projection). The Greek anatomy — ::lemma, ::grammata, ::hypograph, ::taxis — plus the friendly aliases (::title, ::body, ::attribution, ::ord), answered here because this adapter’s property surface IS the vocabulary; on data adapters those spellings stay ordinary field names. The Greek is canon in docs and reflection preserves whichever spelling was written.

Source§

fn default_value(&self, node: NodeId) -> Option<Value>

The default projection is the flattened prose of the subtree — lemma first, hypograph last.

The edge label is the family name both ends share — ->footnote / ->endnote — the node’s own kind, since resolution re-kinds an open-family callout to its body.

Source§

fn resolve( &self, node: NodeId, property: &str, hint: Option<&str>, ) -> Option<NodeId>

//ref-->: land on the bearer — the block if a block bears the name, the point anchor if a point does. The text-level hints choose the reading: -->block normalizes a point landing to its enclosing block, -->point selects point targets only; bare is the honest exact landing.

Source§

fn ref_property(&self, node: NodeId) -> Option<String>

The bare arrow’s property: a ref resolves its target.

Source§

fn external_ref( &self, node: NodeId, property: &str, hint: Option<&str>, ) -> Option<String>

A ref the producer declared external: the absolute URL, relative targets joined against the document’s own URL — the same acquisition rung the html DOM reading speaks.

Source§

fn resolve_fragment(&self, _node: NodeId, fragment: &str) -> Option<NodeId>

A sibling document’s #fragment lands here: the bearer of that name — a labeled block, or a point anchor.

Source§

fn aliased_metadata(&self, _node: NodeId) -> &'static [&'static str]

Ruling #29: the text level’s surface is the vocabulary itself — no document can introduce a property name — so its two annotations answer at :: as well.

Source§

fn metadata(&self, node: NodeId, key: &str) -> Option<Value>

::::level on sections (the source heading level) and ::::lang on verbatim blocks (the declared language).

Source§

fn root(&self) -> NodeId

The root node — the initial navigation context.
Source§

fn children(&self, node: NodeId) -> Vec<NodeId>

The tree children of node, in document order. Read more
Source§

fn name(&self, node: NodeId) -> Option<String>

The name of node — the label of its incoming tree edge. Read more
Source§

fn parent(&self, node: NodeId) -> Option<NodeId>

The parent of node, or None for the root.
Incoming crosslinks to node, as (label, source) pairs, for <- navigation. May be expensive (an adapter that does not precompute edges must search for referrers).
Source§

fn children_named(&self, node: NodeId, name: &str) -> Vec<NodeId>

The children of node whose edge name is exactly name — the engine’s fast path for name-matcher child hops. The default filters children; an adapter whose containers cannot be enumerated (permission-scoped or unbounded remote trees) overrides this with a direct, name-addressed lookup. Must be observationally identical to the default wherever enumeration works. The adapter owns the name test: it may deliberately alias — resolve a name to a node whose edge name differs (git revision syntax landing on a hash-named commit) — and the engine will not re-filter. Container-scoped resolution like that stays child-axis only; per-node spelling aliases belong in answers_to, which this default consults.
Source§

fn answers_to(&self, node: NodeId, name: &str) -> bool

Whether node answers to name as a literal spelling (ruling #30). The default is canonical equality. An adapter may declare per-node aliases — a social feed spelling a handle @alice while the stripped alice is the hop name — and the engine consults this wherever a literal name is matched, on every axis, so one override keeps /@alice and //@alice in agreement. :::name stays canonical (locators and reflection print it; an alias is a way in, never a way out), and name patterns (~(...), *) test the canonical name only.
Source§

fn has_trait(&self, node: NodeId, name: &str) -> bool

Whether node bears name as a trait, as written in a <...> clause. The default is membership in traits; an adapter may declare aliases the way answers_to does for names — a model file’s alias <chunk> <block>; or alias <s/^tag://i>; — and the engine consults this wherever a written trait is matched. Reflection and serialization print the canonical traits only.
Source§

fn ref_label(&self, _node: NodeId, _property: &str) -> Option<String>

The relation name a resolution edge from node via property carries — html’s rel attribute. None falls back to the property name as the edge label.
A property of the crosslink source --label--> target — the $-::prop read. Adapters whose edges carry data (a property graph’s relationship properties) override this; None if the edge is bare or unknown. Where parallel edges share source, label, and target, the adapter answers for one of them, consistently.
Source§

fn document_by_ref(&self, _id: &str) -> Option<NodeId>

The document this arbor holds under an external-reference identifier (a URL, fragment-stripped), when it can answer without the host’s registration: the landing rung of --> after the mounted-document table misses. An adapter over a store of pages answers by URL lookup; the engine performs no IO either way.
Source§

fn reverse_resolve( &self, _node: NodeId, _property: Option<&str>, _hint: Option<&str>, ) -> Option<Vec<NodeId>>

Every node whose property (or, when None, own reference property) resolves to node, in document order — the reverse index behind <--. None keeps the engine’s walk of the whole arbor; Some is the adapter’s complete answer.
Source§

fn descendants_named( &self, _node: NodeId, _name: &str, ) -> Option<Vec<(NodeId, usize)>>

The descendants of node that answer to name, each with its depth (children are depth 1), in document order — the fast path behind //name for an adapter whose substrate indexes names. None keeps the engine’s walk; Some must be exactly what the walk would find.
A batching hint: the engine is about to follow dir crosslinks from every node in nodes. An adapter backed by a store may fetch them in one statement; semantics are unchanged either way.
Source§

fn quantifier_bound(&self) -> usize

The quantifier bound N_max: the depth to which open-ended path quantifiers (+, *, {m,}) expand, and the ceiling of any explicit {m,n} (the effective upper bound is min(n, N_max)). An adapter whose natural structures run deep may raise it; the CLI overrides it per run (qua --quantifier-bound).
Source§

fn allow_shell(&self) -> bool

Whether the sh(...) pipeline stage may run external commands. False by default — query text stays inert data — and enabled per run by the CLI (qua --allow-shell) through the AllowShell wrapper.
Source§

fn invocation_instant(&self) -> Option<(i64, u32)>

The invocation instant now() denotes (spec: The Temporal Fragment, Determinism): one UTC timeline point bound by the runner BEFORE evaluation begins — evaluation itself never reads a clock. None by default (a library run is fully deterministic; now() reads as null); the CLI binds it at startup — pinnable with qua --now — through the WithNow wrapper.
Source§

fn provenance(&self, _node: NodeId) -> Provenance

The data provenance of node — the :::source / :::instant / :::dpid / :::provenance core-metadata keys. Empty by default: an adapter answers only the components its substrate genuinely records (never the invocation clock); wrapper adapters fill missing components from what they know — the mount its target, a graft its outer leaf, a model its derivation — and forward the rest inward, so resolution is nearest-ancestor per component.
Source§

fn has_node(&self, node: NodeId) -> bool

Whether node is an id this adapter minted — the guard behind the node-id anchor ((!N)), which may name an id from an earlier run (ids are minted deterministically: the same source, the same ids). The default probes the id through parent and name and treats a panic as absence, so an adapter that indexes by id needs no override; one that can answer cheaply should.
Source§

fn provenance_list(&self, node: NodeId) -> ProvenanceList

The data provenance of node as a list — every source the substrate records for the datum, and how many it elides. The default is the singular answer as a one-entry list; an adapter whose substrate records several (kaiv’s ?a;b;+N) overrides it, and a wrapper layers each entry.
Source§

fn unit_scale(&self, expr: &str) -> Option<(f64, String)>

The scale of a unit expression — (factor, canonical SI-base expansion) — for the unital reading’s criterion text (spec: The Quantital Fragment). The default answers from the engine’s frozen built-in table; a unit-aware adapter (kaiv) overrides it to include the mounted document’s own custom units, so [::range < '50kellicam'] resolves through the document’s .!units imports.

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