Skip to main content

ReadOnlyNetwork

Struct ReadOnlyNetwork 

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

Compile-time read-only view over a shared links network.

ReadOnlyNetwork derefs to &LinkNetwork, so every non-mutating public operation is reachable while the &mut self mutators (insert_link, set_references, set_span, set_flags, apply_substitution, …) are unreachable: there is no DerefMut, so the borrow checker rejects any attempt to call them. The wrapped network is held behind an Arc, so cloning a view shares one allocation rather than copying the network.

Read-only operations compile and run:

use meta_language::{LinkNetwork, ParseConfiguration};

let view = LinkNetwork::parse("alpha", "plain-text", ParseConfiguration::default()).freeze();
assert_eq!(view.reconstruct_text(), "alpha");

Mutation does not compile, because the mutators require &mut LinkNetwork and the view only ever yields &LinkNetwork:

use meta_language::{LinkMetadata, LinkNetwork, ParseConfiguration};

let view = LinkNetwork::parse("alpha", "plain-text", ParseConfiguration::default()).freeze();
view.insert_link([], LinkMetadata::new()); // error: cannot borrow as mutable

Implementations§

Source§

impl ReadOnlyNetwork

Source

pub fn new(network: LinkNetwork) -> Self

Freezes an owned network into a read-only view.

Source

pub const fn from_shared(network: Arc<LinkNetwork>) -> Self

Wraps an already shared network as a read-only view.

This reuses the existing allocation, allowing read-only access to compose with snapshot versioning without re-cloning the network.

Source

pub fn network(&self) -> &LinkNetwork

Borrows the underlying immutable network.

Source

pub const fn shared(&self) -> &Arc<LinkNetwork>

Borrows the shared network handle.

Source

pub fn into_shared(self) -> Arc<LinkNetwork>

Consumes the view and returns the shared network handle.

Source

pub fn shared_count(&self) -> usize

Number of handles sharing the frozen network allocation.

Source

pub fn to_mutable(&self) -> LinkNetwork

Forks an editable copy so callers can return to a mutable engine.

Source

pub fn into_mutable(self) -> LinkNetwork

Consumes the view and returns an editable network, reusing the allocation when this is the only handle and cloning otherwise.

Methods from Deref<Target = LinkNetwork>§

Source

pub fn as_read_only(&self) -> ReadOnlyNetwork

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

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

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

pub fn self_description_text(&self) -> String

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

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 reconstruct_concept(&self, concept: &str, language: &str) -> Option<&str>

Reconstructs a concept using a target language syntax mapping.

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 verify_full_match(&self, region: Option<ByteRange>) -> VerificationReport

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

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

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

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.

Trait Implementations§

Source§

impl Clone for ReadOnlyNetwork

Source§

fn clone(&self) -> ReadOnlyNetwork

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 ReadOnlyNetwork

Source§

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

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

impl Deref for ReadOnlyNetwork

Source§

type Target = LinkNetwork

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<LinkNetwork> for ReadOnlyNetwork

Source§

fn from(network: LinkNetwork) -> Self

Converts to this type from the input type.
Source§

impl LinkStore for ReadOnlyNetwork

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 ReadOnlyNetwork

Source§

fn eq(&self, other: &Self) -> 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 ReadOnlyNetwork

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.