Skip to main content

LinkNetwork

Struct LinkNetwork 

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

Mutable links network for CST, AST, semantic, and self-description links.

Implementations§

Source§

impl LinkNetwork

Source

pub fn freeze(self) -> ReadOnlyNetwork

Freezes this network into a read-only view, consuming it.

Mutators are unreachable on the returned ReadOnlyNetwork at compile time; only &self operations remain available.

Source

pub fn as_read_only(&self) -> ReadOnlyNetwork

Returns a read-only view sharing a clone of this network.

Source

pub fn parse_engine( text: &str, language: &str, configuration: ParseConfiguration, ) -> EngineNetwork

Parses source text honouring the configured engine access mode.

Under AccessMode::Mutable (the default) this returns an editable network; under AccessMode::ReadOnly it returns the frozen form, where mutation attempts at the engine boundary fail with a clear diagnostic.

Source§

impl LinkNetwork

Source

pub fn parse_fluent( text: &str, language: &str, configuration: ParseConfiguration, ) -> FluentPipeline

Parses source text and starts a fluent chain.

Applies a link-cli-style substitution command.

§Errors

Returns LinkCliSubstitutionError when the command text is malformed.

Source§

impl LinkNetwork

Source

pub fn seed_common_concept_ontology(&mut self) -> ConceptOntologySeedReport

Seeds the network with the shared common concept ontology.

The seed combines meta-expression’s semantic lexicon with structural programming-language concepts that are shared across the current language targets.

Source

pub fn intern_concept( &mut self, exact_id: &str, definition: Option<&str>, ) -> LinkId

Interns a language-free concept by exact identifier.

The identifier is matched exactly: case changes, diacritic changes, or sense suffixes are distinct concept ids and therefore produce distinct concept links.

Source

pub fn insert_concept_expression( &mut self, concept: &str, language: &str, expression: &str, ) -> LinkId

Inserts a language-bound expression linked to a language-free concept.

The concept is reused only when concept exactly matches an existing concept id; otherwise a new concept link is minted.

Source

pub fn insert_concept_mapping( &mut self, concept: &str, language: &str, syntax: &str, ) -> LinkId

Inserts a concept-to-language syntax mapping and returns the semantic link id.

Source

pub fn insert_concept_alias( &mut self, concept_link: LinkId, vocabulary: &str, external_id: &str, ) -> LinkId

Attaches an external vocabulary id to a concept without changing its exact concept id.

Source

pub fn import_concept_ontology_lino( &mut self, text: &str, ) -> Result<ConceptOntologyImportReport, LinoSerializationError>

Imports concept, expression, and alias links from canonical LiNo text.

The input is the links-notation text produced by LinkNetwork::to_lino. Importing the same text repeatedly is idempotent because concepts, expressions, and aliases are all deduplicated by exact link shape.

Source§

impl LinkNetwork

Source

pub fn render_markup_document( &self, language: &str, document: &FormattingDocument, ) -> String

Renders a language-free FormattingDocument (the concept layer) into language surface syntax using the seeded per-format templates.

Source

pub fn translate_markup_document( &self, source_language: &str, target_language: &str, text: &str, ) -> Option<String>

Parses text written in source_language into the language-free concept layer, then renders it as target_language surface syntax.

This is the cross-format reconstruction substrate: a Markdown document using bold/italic/heading/list/link round-trips to HTML and back through the shared concept ontology.

Source§

impl LinkNetwork

Source

pub fn seed_document_formatting_concepts( &mut self, ) -> DocumentFormattingSeedReport

Seeds the shared document-formatting concept set with per-format syntax mappings.

Each concept becomes a language-free LinkType::Concept link, and each (language, template) pair becomes a semantic syntax mapping so the same concept reconstructs as **…** in Markdown, <strong>…</strong> in HTML, and so on.

Source

pub fn resolve_document_format( &self, language: &str, fragment: &str, ) -> Option<DocumentFormatMatch>

Resolves a formatting fragment written in language to the shared, language-free concept it denotes.

Both Markdown **bold** and HTML <strong>bold</strong> resolve to the one seeded strong concept link. Returns None when the fragment is not a known formatting construct or the concept set has not been seeded.

Source

pub fn render_document_format( &self, concept: &str, language: &str, instance: &DocumentFormatInstance, ) -> Option<String>

Renders a concept instance into language surface syntax.

Returns None when the concept has no template for the language or a required attribute is missing from the instance.

Source

pub fn translate_document_format( &self, source_language: &str, target_language: &str, fragment: &str, ) -> Option<String>

Translates a single formatting fragment from source_language to target_language through the shared concept layer.

Source

pub fn document_formatting_concept(&self, concept: &str) -> Option<LinkId>

Returns the seeded concept link for a formatting concept id, when present.

Source§

impl LinkNetwork

Source

pub fn apply_edit(&mut self, range: ByteRange, replacement: &str) -> bool

Applies a byte-range source edit and reparses the network.

Tree-sitter-backed languages use tree-sitter’s incremental parse path; other languages fall back to the built-in lossless parser. Links whose source spans are outside the replaced byte range keep their identifiers.

Source

pub fn apply_edit_with_configuration( &mut self, range: ByteRange, replacement: &str, configuration: ParseConfiguration, ) -> bool

Applies a byte-range source edit using an explicit parse configuration.

Returns false when the range is outside the reconstructed source text, splits a UTF-8 code point, or the network has no document language.

Source§

impl LinkNetwork

Source

pub const fn new() -> Self

Creates an empty links network.

Source

pub fn self_describing() -> Self

Creates a links network containing the common self-description roots.

Source

pub fn self_description_text(&self) -> String

Serializes the seeded self-description roots as LiNo-style definition lines.

Source

pub fn parse( text: &str, language: &str, configuration: ParseConfiguration, ) -> Self

Parses plain source text into a lossless token network.

This is the default parse operation. It is lossless by construction; use LinkNetwork::projected_links when a lower-level view should be stripped away for CST, AST, or semantic-only work.

Source

pub fn parse_lossless_text( text: &str, language: &str, configuration: ParseConfiguration, ) -> Self

Parses plain source text into a lossless token network.

This parser boundary preserves source spans, trivia links, recovery markers, and mixed-region metadata behind the same network representation.

Source

pub fn len(&self) -> usize

Number of links in the network.

Source

pub fn is_empty(&self) -> bool

Whether the network contains no links.

Number of network handles sharing one immutable link allocation.

Source

pub fn interned_string_count(&self, value: &str) -> Option<usize>

Number of internal handles sharing an interned string value.

Iterates over links in identifier order.

Iterates over links included in the selected projection.

Source

pub fn reconstruct_text(&self) -> String

Reconstructs source text from non-missing token links ordered by span.

Source

pub fn embedded_regions(&self) -> Vec<EmbeddedRegion>

Returns embedded mixed-language regions discovered during parse.

Returns links matching a structural query.

Source

pub fn query_matches(&self, query: &LinkQuery) -> Vec<QueryMatch>

Returns query matches with capture bindings.

Source

pub fn query_matches_with( &self, query: &LinkQuery, predicate_host: &impl QueryPredicateHost, ) -> Vec<QueryMatch>

Returns query matches with host-evaluated predicate support.

Source

pub fn insert_point(&mut self, term: &str) -> LinkId

Inserts a self-referential point link for a term.

Source

pub fn insert_object(&mut self, term: &str) -> LinkId

Inserts an object-identity point link.

Source

pub fn insert_relation<const N: usize>( &mut self, references: [LinkId; N], link_type: LinkType, span: SourceSpan, ) -> LinkId

Inserts a relation link with source span metadata.

Source

pub fn insert_field( &mut self, parent: LinkId, label: &str, child: LinkId, ) -> LinkId

Inserts a labeled field relation as a regular link.

Inserts a link from references and metadata.

Source

pub fn reconstruct_concept(&self, concept: &str, language: &str) -> Option<&str>

Reconstructs a concept using a target language syntax mapping.

Source

pub fn apply_substitution( &mut self, rule: &SubstitutionRule, ) -> SubstitutionReport

Applies a match-and-substitute rule over exact reference lists.

Source

pub fn apply_variable_substitution( &mut self, rule: &VariableSubstitutionRule, ) -> SubstitutionReport

Applies a match-and-substitute rule with link-cli-style variables.

Returns a link by id.

Source

pub fn find_term(&self, term: &str) -> Option<LinkId>

Finds a self-description or named term link.

Source

pub fn definition_for(&self, id: LinkId) -> Option<&str>

Finds the definition attached to a term link.

Source

pub fn set_span(&mut self, id: LinkId, span: SourceSpan) -> bool

Sets a source span on an existing link.

Source

pub fn set_flags(&mut self, id: LinkId, flags: LinkFlags) -> bool

Sets parse flags on an existing link.

Source

pub fn verify_full_match(&self, region: Option<ByteRange>) -> VerificationReport

Verifies that the selected region has no error or missing links.

Source§

impl LinkNetwork

Source

pub fn to_lino(&self) -> String

Serializes the entire network to canonical links-notation text.

Every link becomes one statement keyed by its numeric id. The output is accepted by the [links_notation] crate parser and round-trips back through LinkNetwork::from_lino.

Source

pub fn from_lino(text: &str) -> Result<Self, LinoSerializationError>

Reconstructs a network from text produced by LinkNetwork::to_lino.

§Errors

Returns LinoSerializationError when the text is not valid links-notation or does not match the serialization schema.

Source§

impl LinkNetwork

Source

pub fn parse_with_registry( registry: &ParserRegistry, text: &str, language: &str, configuration: ParseConfiguration, ) -> Self

Parses source text through a pluggable ParserRegistry.

Dispatch honors user registrations, which shadow the built-in set for the same language key; keys without an explicit registration fall through to the same built-in dispatch LinkNetwork::parse uses.

Source§

impl LinkNetwork

Source

pub fn reconstruct_text_as( &self, target_language: &str, configuration: ParseConfiguration, ) -> String

Reconstructs text for a target language or formalization level.

Natural same-language reconstruction returns the original byte-exact token stream. When semantic proposition links are available, target natural-language text and configured formal representations are rendered through the shared concept mappings.

Source

pub fn reconstruct_text_as_with_rules( &self, target_language: &str, configuration: ParseConfiguration, rule_set: &TranslationRuleSet, ) -> String

Reconstructs text using a caller-supplied translation rule set.

Source

pub fn reconstruct_text_as_with_registry( &self, target_language: &str, configuration: ParseConfiguration, registry: &TranslationRuleRegistry, ) -> String

Reconstructs text through the active rule set in a registry.

Source

pub fn reconstruct_text_as_with_rules_mut( &mut self, target_language: &str, configuration: ParseConfiguration, rule_set: &TranslationRuleSet, ) -> String

Reconstructs text and records diagnostic links when no rule can render it.

Source§

impl LinkNetwork

Source

pub fn insert_object_instance(&mut self, type_id: LinkId) -> LinkId

Inserts an anonymous object identity linked to its Rust/meta type.

The resulting object references itself first, preserving a stable identity link for shared and circular object graphs, and references the type shape second so the object’s declaration remains queryable.

Source§

impl LinkNetwork

Source

pub fn snapshot( &self, version: u64, provenance: impl Into<String>, ) -> NetworkSnapshot

Captures the current network as an immutable versioned snapshot.

Source

pub fn structural_diff(&self, other: &Self) -> StructuralDiff

Computes changed, added, and removed link ids against another network.

Source§

impl LinkNetwork

Source

pub fn insert_source_token(&mut self, language: &str, text: &str) -> LinkId

Inserts a source token that can be rendered without an original source span.

This is the construction-side counterpart to parser-created token links: the token text is stored in the link term, but no byte range is required.

Source

pub fn insert_syntax_node<const N: usize>( &mut self, language: &str, kind: &str, children: [LinkId; N], ) -> LinkId

Inserts a syntax node whose ordered references are renderable children.

The kind should match the grammar node vocabulary used by the corresponding parser where possible. Rendering only emits descendant token text; the kind is metadata for queries and round-trip validation.

Source

pub fn render_source(&self, language: &str) -> String

Renders source text for language from a parsed or constructed network.

Parsed networks are rendered from their document root. Hand-built networks without document links are rendered from top-level syntax or token links whose metadata language matches language.

Source

pub fn render_source_from(&self, root: LinkId, language: &str) -> String

Renders source text from a specific syntax, document, region, or token link.

Source

pub fn render_source_from_document(&self, language: &str) -> Option<String>

Renders source text from document links matching language.

Returns None when the network has no matching document link, which is common for programmatically constructed syntax fragments.

Source§

impl LinkNetwork

Source

pub fn find(&self, query: &LinkQuery) -> Vec<QueryMatch>

Finds query matches using the transform surface’s source-text predicates.

This delegates structural matching to LinkQuery’s S-expression matcher. Built-in predicates such as #eq? @capture "text" compare the text reconstructed from captured token links.

Source

pub fn replace( &mut self, matches: &[QueryMatch], rule: &ReplacementRule, ) -> ReplacementReport

Applies a replacement rule to links selected by LinkNetwork::find.

Source

pub fn replace_with_profile( &mut self, matches: &[QueryMatch], rule: &ReplacementRule, profile: &LanguageProfile, ) -> ReplacementReport

Applies a replacement only when the result stays inside a language profile.

The replacement is first evaluated on a cloned network. If the candidate network validates against the profile, it is committed to self. If the profile rejects it, self keeps its original source text and receives a queryable language-profile:unsupported-feature diagnostic link.

Trait Implementations§

Source§

impl Clone for LinkNetwork

Source§

fn clone(&self) -> LinkNetwork

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LinkNetwork

Source§

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

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

impl Default for LinkNetwork

Source§

fn default() -> LinkNetwork

Returns the “default value” for a type. Read more
Source§

impl FluentNetworkApi for LinkNetwork

Source§

fn into_network(self) -> LinkNetwork

Converts self into the underlying network executor.
Source§

fn into_fluent(self) -> FluentPipeline

Starts a fluent chain over the same network executor.
Source§

impl From<LinkNetwork> for ReadOnlyNetwork

Source§

fn from(network: LinkNetwork) -> Self

Converts to this type from the input type.
Source§

impl LinkStore for LinkNetwork

Source§

fn create( &mut self, references: &[LinkId], metadata: LinkMetadata, ) -> Result<LinkId, StorageError>

Creates a link and returns its stable id. Read more
Source§

fn read(&self, id: LinkId) -> Result<Option<Link>, StorageError>

Reads a link by id. Read more
Source§

fn update( &mut self, id: LinkId, references: &[LinkId], metadata: LinkMetadata, ) -> Result<bool, StorageError>

Replaces an existing link’s references and metadata. Read more
Source§

fn delete(&mut self, id: LinkId) -> Result<bool, StorageError>

Deletes a link by id. Read more
Source§

fn search(&self, query: &LinkStoreQuery) -> Result<Vec<Link>, StorageError>

Returns links matching query. Read more
Source§

fn count(&self, query: &LinkStoreQuery) -> Result<usize, StorageError>

Counts links matching query. Read more
Source§

impl PartialEq for LinkNetwork

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LinkNetwork

Source§

impl StructuralPartialEq for LinkNetwork

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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
§

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

§

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

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

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

§

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

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

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

§

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

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
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
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 = 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.