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 mutableImplementations§
Source§impl ReadOnlyNetwork
impl ReadOnlyNetwork
Sourcepub fn new(network: LinkNetwork) -> Self
pub fn new(network: LinkNetwork) -> Self
Freezes an owned network into a read-only view.
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.
Sourcepub fn network(&self) -> &LinkNetwork
pub fn network(&self) -> &LinkNetwork
Borrows the underlying immutable network.
Borrows the shared network handle.
Consumes the view and returns the shared network handle.
Number of handles sharing the frozen network allocation.
Sourcepub fn to_mutable(&self) -> LinkNetwork
pub fn to_mutable(&self) -> LinkNetwork
Forks an editable copy so callers can return to a mutable engine.
Sourcepub fn into_mutable(self) -> LinkNetwork
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>§
Sourcepub fn as_read_only(&self) -> ReadOnlyNetwork
pub fn as_read_only(&self) -> ReadOnlyNetwork
Returns a read-only view sharing a clone of this network.
Sourcepub fn render_markup_document(
&self,
language: &str,
document: &FormattingDocument,
) -> String
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.
Sourcepub fn translate_markup_document(
&self,
source_language: &str,
target_language: &str,
text: &str,
) -> Option<String>
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.
Sourcepub fn resolve_document_format(
&self,
language: &str,
fragment: &str,
) -> Option<DocumentFormatMatch>
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.
Sourcepub fn render_document_format(
&self,
concept: &str,
language: &str,
instance: &DocumentFormatInstance,
) -> Option<String>
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.
Sourcepub fn translate_document_format(
&self,
source_language: &str,
target_language: &str,
fragment: &str,
) -> Option<String>
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.
Sourcepub fn document_formatting_concept(&self, concept: &str) -> Option<LinkId>
pub fn document_formatting_concept(&self, concept: &str) -> Option<LinkId>
Returns the seeded concept link for a formatting concept id, when present.
Sourcepub fn self_description_text(&self) -> String
pub fn self_description_text(&self) -> String
Serializes the seeded self-description roots as LiNo-style definition lines.
Number of network handles sharing one immutable link allocation.
Sourcepub fn interned_string_count(&self, value: &str) -> Option<usize>
pub fn interned_string_count(&self, value: &str) -> Option<usize>
Number of internal handles sharing an interned string value.
Sourcepub fn projected_links(
&self,
projection: NetworkProjection,
) -> impl Iterator<Item = &Link>
pub fn projected_links( &self, projection: NetworkProjection, ) -> impl Iterator<Item = &Link>
Iterates over links included in the selected projection.
Sourcepub fn reconstruct_text(&self) -> String
pub fn reconstruct_text(&self) -> String
Reconstructs source text from non-missing token links ordered by span.
Sourcepub fn embedded_regions(&self) -> Vec<EmbeddedRegion>
pub fn embedded_regions(&self) -> Vec<EmbeddedRegion>
Returns embedded mixed-language regions discovered during parse.
Sourcepub fn query_links(&self, query: &LinkQuery) -> Vec<&Link>
pub fn query_links(&self, query: &LinkQuery) -> Vec<&Link>
Returns links matching a structural query.
Sourcepub fn query_matches(&self, query: &LinkQuery) -> Vec<QueryMatch>
pub fn query_matches(&self, query: &LinkQuery) -> Vec<QueryMatch>
Returns query matches with capture bindings.
Sourcepub fn query_matches_with(
&self,
query: &LinkQuery,
predicate_host: &impl QueryPredicateHost,
) -> Vec<QueryMatch>
pub fn query_matches_with( &self, query: &LinkQuery, predicate_host: &impl QueryPredicateHost, ) -> Vec<QueryMatch>
Returns query matches with host-evaluated predicate support.
Sourcepub fn reconstruct_concept(&self, concept: &str, language: &str) -> Option<&str>
pub fn reconstruct_concept(&self, concept: &str, language: &str) -> Option<&str>
Reconstructs a concept using a target language syntax mapping.
Sourcepub fn find_term(&self, term: &str) -> Option<LinkId>
pub fn find_term(&self, term: &str) -> Option<LinkId>
Finds a self-description or named term link.
Sourcepub fn definition_for(&self, id: LinkId) -> Option<&str>
pub fn definition_for(&self, id: LinkId) -> Option<&str>
Finds the definition attached to a term link.
Sourcepub fn verify_full_match(&self, region: Option<ByteRange>) -> VerificationReport
pub fn verify_full_match(&self, region: Option<ByteRange>) -> VerificationReport
Verifies that the selected region has no error or missing links.
Sourcepub fn to_lino(&self) -> String
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.
Sourcepub fn reconstruct_text_as(
&self,
target_language: &str,
configuration: ParseConfiguration,
) -> String
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.
Sourcepub fn reconstruct_text_as_with_rules(
&self,
target_language: &str,
configuration: ParseConfiguration,
rule_set: &TranslationRuleSet,
) -> String
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.
Sourcepub fn reconstruct_text_as_with_registry(
&self,
target_language: &str,
configuration: ParseConfiguration,
registry: &TranslationRuleRegistry,
) -> String
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.
Sourcepub fn snapshot(
&self,
version: u64,
provenance: impl Into<String>,
) -> NetworkSnapshot
pub fn snapshot( &self, version: u64, provenance: impl Into<String>, ) -> NetworkSnapshot
Captures the current network as an immutable versioned snapshot.
Sourcepub fn structural_diff(&self, other: &Self) -> StructuralDiff
pub fn structural_diff(&self, other: &Self) -> StructuralDiff
Computes changed, added, and removed link ids against another network.
Sourcepub fn render_source(&self, language: &str) -> String
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.
Sourcepub fn render_source_from(&self, root: LinkId, language: &str) -> String
pub fn render_source_from(&self, root: LinkId, language: &str) -> String
Renders source text from a specific syntax, document, region, or token link.
Sourcepub fn render_source_from_document(&self, language: &str) -> Option<String>
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.
Sourcepub fn find(&self, query: &LinkQuery) -> Vec<QueryMatch>
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
impl Clone for ReadOnlyNetwork
Source§fn clone(&self) -> ReadOnlyNetwork
fn clone(&self) -> ReadOnlyNetwork
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReadOnlyNetwork
impl Debug for ReadOnlyNetwork
Source§impl Deref for ReadOnlyNetwork
impl Deref for ReadOnlyNetwork
Source§impl From<LinkNetwork> for ReadOnlyNetwork
impl From<LinkNetwork> for ReadOnlyNetwork
Source§fn from(network: LinkNetwork) -> Self
fn from(network: LinkNetwork) -> Self
Source§impl LinkStore for ReadOnlyNetwork
impl LinkStore for ReadOnlyNetwork
Source§fn create(
&mut self,
_references: &[LinkId],
_metadata: LinkMetadata,
) -> Result<LinkId, StorageError>
fn create( &mut self, _references: &[LinkId], _metadata: LinkMetadata, ) -> Result<LinkId, StorageError>
Source§fn read(&self, id: LinkId) -> Result<Option<Link>, StorageError>
fn read(&self, id: LinkId) -> Result<Option<Link>, StorageError>
Source§fn update(
&mut self,
_id: LinkId,
_references: &[LinkId],
_metadata: LinkMetadata,
) -> Result<bool, StorageError>
fn update( &mut self, _id: LinkId, _references: &[LinkId], _metadata: LinkMetadata, ) -> Result<bool, StorageError>
Source§fn delete(&mut self, _id: LinkId) -> Result<bool, StorageError>
fn delete(&mut self, _id: LinkId) -> Result<bool, StorageError>
Source§fn search(&self, query: &LinkStoreQuery) -> Result<Vec<Link>, StorageError>
fn search(&self, query: &LinkStoreQuery) -> Result<Vec<Link>, StorageError>
query. Read moreSource§fn count(&self, query: &LinkStoreQuery) -> Result<usize, StorageError>
fn count(&self, query: &LinkStoreQuery) -> Result<usize, StorageError>
query. Read moreSource§impl PartialEq for ReadOnlyNetwork
impl PartialEq for ReadOnlyNetwork
impl Eq for ReadOnlyNetwork
Auto Trait Implementations§
impl Freeze for ReadOnlyNetwork
impl RefUnwindSafe for ReadOnlyNetwork
impl Send for ReadOnlyNetwork
impl Sync for ReadOnlyNetwork
impl Unpin for ReadOnlyNetwork
impl UnsafeUnpin for ReadOnlyNetwork
impl UnwindSafe for ReadOnlyNetwork
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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