pub struct LinkStorage { /* private fields */ }Expand description
LinkStorage provides persistent storage for links Corresponds to the storage functionality in NamedLinksDecorator in C#
Implementations§
Source§impl LinkStorage
impl LinkStorage
Sourcepub fn new<P: AsRef<Path>>(db_path: P, trace: bool) -> Result<Self>
pub fn new<P: AsRef<Path>>(db_path: P, trace: bool) -> Result<Self>
Creates a new LinkStorage instance
The database location is accepted as any AsRef<Path>, so
embedding applications can pass a PathBuf (or an OsStr on
platforms with non-UTF-8 paths) instead of a &str.
Sourcepub fn database_path(&self) -> &Path
pub fn database_path(&self) -> &Path
The database file this storage reads from and writes to.
Sourcepub fn observed_revision(&self) -> StorageRevision
pub fn observed_revision(&self) -> StorageRevision
The revision of the database file observed at the last load or save.
Sourcepub fn refresh_observed_revision(&mut self) -> Result<(), LinkError>
pub fn refresh_observed_revision(&mut self) -> Result<(), LinkError>
Re-reads the database file’s revision fingerprint, marking the
current on-disk state as “seen” for
LinksStorage::has_external_changes.
Sourcepub fn reload_from_disk(&mut self) -> Result<()>
pub fn reload_from_disk(&mut self) -> Result<()>
Discards in-memory state and re-reads the database file.
Sourcepub fn create(&mut self, source: u32, target: u32) -> u32
pub fn create(&mut self, source: u32, target: u32) -> u32
Creates a new link and returns its ID
The address is the one allocate hands out: a freed one
when the store has any, and only otherwise a fresh one past the end.
Sourcepub fn ensure_created(&mut self, id: u32) -> u32
pub fn ensure_created(&mut self, id: u32) -> u32
Creates the link at id, as an empty (id: 0 0) link.
Reaching a specific address means asking the allocator for links until
it hands that one out, and the ones it handed out on the way are freed
again — they were never asked for. This is ILinksExtensions.EnsureCreated
in the C# implementation:
do { createdLink = creator(); createdLinks.Add(createdLink); }
while (createdLink != max);
for (var i = 0; i < createdLinks.Count; i++)
if (!nonExistentAddresses.Contains(createdLinks[i]))
links.Delete(createdLinks[i]);Freeing them in the order they were created is what leaves the last one on top of the free list, so it is the address the next created link gets.
Sourcepub fn update_raw(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
pub fn update_raw(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
Updates a link’s source and target without applying any policy.
This is the raw store operation, the equivalent of writing straight to
UnitedMemoryLinks in the C# implementation. LinkStorage::update
wraps it with the upstream uniqueness/usages decorators; use this method
when you are supplying your own decorator stack (or deliberately want
none).
Sourcepub fn delete_raw(&mut self, id: u32) -> Result<Link>
pub fn delete_raw(&mut self, id: u32) -> Result<Link>
Deletes a link by ID without applying any policy.
The raw counterpart of LinkStorage::delete: it removes exactly the
requested link (and its name), leaving any link that referenced it
dangling.
Sourcepub fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
pub fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
Updates a link’s source and target through the upstream
doublets uniqueness and usages resolution stack.
This mirrors the C# implementation, which always talks to a
UnitedMemoryLinks wrapped in
DecorateWithAutomaticUniquenessAndUsagesResolution(). Concretely: if
another link already holds (source, target), every reference to id
is re-pointed at that link and id is deleted, instead of storing a
duplicate doublet.
Returns the state the link was in before the operation. Use
LinkStorage::update_raw for the undecorated write.
Sourcepub fn update_observed(
&mut self,
id: u32,
source: u32,
target: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
pub fn update_observed( &mut self, id: u32, source: u32, target: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
LinkStorage::update, reporting every change the decorator stack made.
Resolving a duplicate doublet re-points and deletes other links, so one
call can produce several changes. Layers above the storage need to see
all of them — the C# implementation gets them for free because its
decorators forward to a WriteHandler:
var result = _links.Update(restriction, substitution, (before, after) => { ... });observer is that handler. A change with a null after is a deletion.
Sourcepub fn delete(&mut self, id: u32) -> Result<Link>
pub fn delete(&mut self, id: u32) -> Result<Link>
Deletes a link through the upstream doublets uniqueness and usages
resolution stack, cascading to every link that references it.
This mirrors the C# implementation’s
DecorateWithAutomaticUniquenessAndUsagesResolution() behaviour: the
link is reset to (null, null), everything that still references it is
deleted first, and only then is the link itself removed. Cycles
terminate rather than recursing forever.
Returns the state the requested link was in before the operation. Use
LinkStorage::delete_raw for the undecorated removal.
Sourcepub fn delete_observed(
&mut self,
id: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
pub fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
LinkStorage::delete, reporting every change the decorator stack made.
A cascading delete removes every link that still referenced id, so one
call can produce several changes; see LinkStorage::update_observed.
Sourcepub fn all(&self) -> Vec<&Link> ⓘ
pub fn all(&self) -> Vec<&Link> ⓘ
Every stored link, ordered by address.
The order is part of the contract, not an implementation detail: the
query processor enumerates links through this method, so an
unspecified order would make pattern matching — and with it the order
--changes reports and the order a cascading delete visits usages —
vary between runs of the very same query. HashMap::values is exactly
such an order, seeded randomly per process. Sorting reproduces what the
C# store does naturally: UnitedMemoryLinks walks allocated addresses
from 1 upwards.
Sourcepub fn query(
&self,
index: Option<u32>,
source: Option<u32>,
target: Option<u32>,
) -> Vec<&Link> ⓘ
pub fn query( &self, index: Option<u32>, source: Option<u32>, target: Option<u32>, ) -> Vec<&Link> ⓘ
Returns all links matching a query pattern
Sourcepub fn search(&self, source: u32, target: u32) -> Option<u32>
pub fn search(&self, source: u32, target: u32) -> Option<u32>
Searches for a link with the given source and target.
When several links share the pair, the lowest address wins, so the result never depends on hash map iteration order.
Sourcepub fn get_or_create(&mut self, source: u32, target: u32) -> u32
pub fn get_or_create(&mut self, source: u32, target: u32) -> u32
Gets or creates a link with the given source and target.
The two calls are fully qualified on purpose. LinkStorage also
implements the upstream Doublets trait — including for
&mut LinkStorage, so that a borrowed store can be decorated — and
inside an inherent &mut self method the receiver’s type is exactly
&mut LinkStorage. Method resolution reaches the trait impl on the
reference before it derefs to the inherent impl, so a bare
self.search(..) silently resolves to Doublets::search, which
interprets LinksConstants::any as a
wildcard instead of matching it literally. Naming the inherent methods
keeps the exact-match semantics this function documents.
Sourcepub fn format_lino(&self, link: &Link) -> String
pub fn format_lino(&self, link: &Link) -> String
Formats a link as LiNo suitable for database export.
Sourcepub fn lino_lines(&self) -> Vec<String>
pub fn lino_lines(&self) -> Vec<String>
Returns all database links as sorted LiNo lines.
Sourcepub fn write_lino_output<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn write_lino_output<P: AsRef<Path>>(&self, path: P) -> Result<()>
Writes the complete database as LiNo.
Sourcepub fn format_structure(&self, id: u32) -> Result<String>
pub fn format_structure(&self, id: u32) -> Result<String>
Formats the structure of a link
Sourcepub fn print_all_links(&self)
pub fn print_all_links(&self)
Prints all links
Sourcepub fn print_change(&self, before: &Option<Link>, after: &Option<Link>)
pub fn print_change(&self, before: &Option<Link>, after: &Option<Link>)
Prints a change (before -> after)
Sourcepub fn get_or_create_named(&mut self, name: &str) -> u32
pub fn get_or_create_named(&mut self, name: &str) -> u32
Gets or creates a link with a name
Sourcepub fn get_by_name(&self, name: &str) -> Option<u32>
pub fn get_by_name(&self, name: &str) -> Option<u32>
Gets a link ID by name
Sourcepub fn remove_name(&mut self, id: u32)
pub fn remove_name(&mut self, id: u32)
Removes the name for a link
Sourcepub fn is_trace_enabled(&self) -> bool
pub fn is_trace_enabled(&self) -> bool
Returns true if trace mode is enabled
Trait Implementations§
Source§impl Doublets<u32> for LinkStorage
impl Doublets<u32> for LinkStorage
Source§fn get_link(&self, index: u32) -> Option<DoubletsLink<u32>>
fn get_link(&self, index: u32) -> Option<DoubletsLink<u32>>
index, or None if it does not exist.Source§fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
query.Source§fn create_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn create_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler on each created link.Source§fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns its index.Source§fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
handler with the before/after states.Source§fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
query, calling handler for each.Source§fn each<F>(&self, handler: F) -> Flow
fn each<F>(&self, handler: F) -> Flow
handler for each.Source§fn update_by_with<H>(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
handler: H,
) -> Result<Flow, Error<T>>
fn update_by_with<H>( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, handler: H, ) -> Result<Flow, Error<T>>
query to change, calling handler with before/after.Source§fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
query to change and returns the updated link’s index.Source§fn update_with<F>(
&mut self,
index: T,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn update_with<F>( &mut self, index: T, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
index to (index, source, target), calling handler.Source§fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
index to (index, source, target) and returns the index.Source§fn delete_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn delete_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler with before/after states.Source§fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns the deleted link’s index.Source§fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
index, calling handler with before/after states.Source§fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index and returns its former index.Source§fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
index, or Err(Error::NotExists) if it does not exist.Source§fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
Source§fn delete_query_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<(), Error<T>>
fn delete_query_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<(), Error<T>>
query, calling handler for each deletion.Source§fn delete_usages_with<F>(
&mut self,
index: T,
handler: F,
) -> Result<(), Error<T>>
fn delete_usages_with<F>( &mut self, index: T, handler: F, ) -> Result<(), Error<T>>
index as a source or target, calling handler for each.Source§fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
index as a source or target.Source§fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn create_link_with<F>(
&mut self,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn create_link_with<F>( &mut self, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
source to target, calling handler with before/after states.Source§fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
source to target and returns its index.Source§fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
true if at least one link matches query.Source§fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query, or None.Source§fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
source and target, or None.Source§fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
use search instead
Source§fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query only if exactly one link matches; None otherwise.Source§fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
(source, target) link, creating it if it does not exist.Source§fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index as a source or target.Source§fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
index as a source or target.Source§fn exist(&self, link: T) -> boolwhere
Self: Sized,
fn exist(&self, link: T) -> boolwhere
Self: Sized,
true if the link at link exists (internal or external).Source§fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
true if any other link references link as a source or target.Source§fn rebase_with<F>(&mut self, old: T, new: T, handler: F) -> Result<(), Error<T>>
fn rebase_with<F>(&mut self, old: T, new: T, handler: F) -> Result<(), Error<T>>
old to new, calling handler for each update.Source§impl Doublets<u32> for &mut LinkStorage
impl Doublets<u32> for &mut LinkStorage
Source§fn get_link(&self, index: u32) -> Option<DoubletsLink<u32>>
fn get_link(&self, index: u32) -> Option<DoubletsLink<u32>>
index, or None if it does not exist.Source§fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
fn count_by(&self, query: impl ToQuery<T>) -> Twhere
Self: Sized,
query.Source§fn create_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn create_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler on each created link.Source§fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns its index.Source§fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
handler with the before/after states.Source§fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
query, calling handler for each.Source§fn each<F>(&self, handler: F) -> Flow
fn each<F>(&self, handler: F) -> Flow
handler for each.Source§fn update_by_with<H>(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
handler: H,
) -> Result<Flow, Error<T>>
fn update_by_with<H>( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, handler: H, ) -> Result<Flow, Error<T>>
query to change, calling handler with before/after.Source§fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
fn update_by(
&mut self,
query: impl ToQuery<T>,
change: impl ToQuery<T>,
) -> Result<T, Error<T>>where
Self: Sized,
query to change and returns the updated link’s index.Source§fn update_with<F>(
&mut self,
index: T,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn update_with<F>( &mut self, index: T, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
index to (index, source, target), calling handler.Source§fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
index to (index, source, target) and returns the index.Source§fn delete_by_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<Flow, Error<T>>
fn delete_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
query, calling handler with before/after states.Source§fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>where
Self: Sized,
query and returns the deleted link’s index.Source§fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
index, calling handler with before/after states.Source§fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn delete(&mut self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index and returns its former index.Source§fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>>
index, or Err(Error::NotExists) if it does not exist.Source§fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
fn delete_all(&mut self) -> Result<(), Error<T>>where
Self: Sized,
Source§fn delete_query_with<F>(
&mut self,
query: impl ToQuery<T>,
handler: F,
) -> Result<(), Error<T>>
fn delete_query_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<(), Error<T>>
query, calling handler for each deletion.Source§fn delete_usages_with<F>(
&mut self,
index: T,
handler: F,
) -> Result<(), Error<T>>
fn delete_usages_with<F>( &mut self, index: T, handler: F, ) -> Result<(), Error<T>>
index as a source or target, calling handler for each.Source§fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>where
Self: Sized,
index as a source or target.Source§fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
fn create_point(&mut self) -> Result<T, Error<T>>where
Self: Sized,
Source§fn create_link_with<F>(
&mut self,
source: T,
target: T,
handler: F,
) -> Result<Flow, Error<T>>
fn create_link_with<F>( &mut self, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
source to target, calling handler with before/after states.Source§fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
source to target and returns its index.Source§fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
fn found(&self, query: impl ToQuery<T>) -> boolwhere
Self: Sized,
true if at least one link matches query.Source§fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query, or None.Source§fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
fn search(&self, source: T, target: T) -> Option<T>where
Self: Sized,
source and target, or None.Source§fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
fn search_or(&self, source: T, target: T, default: T) -> Twhere
Self: Sized,
use search instead
Source§fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>where
Self: Sized,
query only if exactly one link matches; None otherwise.Source§fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>where
Self: Sized,
(source, target) link, creating it if it does not exist.Source§fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
fn count_usages(&self, index: T) -> Result<T, Error<T>>where
Self: Sized,
index as a source or target.Source§fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>where
Self: Sized,
index as a source or target.Source§fn exist(&self, link: T) -> boolwhere
Self: Sized,
fn exist(&self, link: T) -> boolwhere
Self: Sized,
true if the link at link exists (internal or external).Source§fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
fn has_usages(&self, link: T) -> boolwhere
Self: Sized,
true if any other link references link as a source or target.Source§fn rebase_with<F>(&mut self, old: T, new: T, handler: F) -> Result<(), Error<T>>
fn rebase_with<F>(&mut self, old: T, new: T, handler: F) -> Result<(), Error<T>>
old to new, calling handler for each update.Source§impl Links<u32> for LinkStorage
impl Links<u32> for LinkStorage
Source§fn constants(&self) -> &LinksConstants<u32>
fn constants(&self) -> &LinksConstants<u32>
LinksConstants (any/null/range values).Source§fn count_links(&self, query: &[u32]) -> u32
fn count_links(&self, query: &[u32]) -> u32
query.Source§fn create_links(
&mut self,
_query: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn create_links( &mut self, _query: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query and reports each creation via handler.Source§fn each_links(&self, query: &[u32], handler: ReadHandler<'_, u32>) -> Flow
fn each_links(&self, query: &[u32], handler: ReadHandler<'_, u32>) -> Flow
query, calling handler for each.Source§fn update_links(
&mut self,
query: &[u32],
change: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn update_links( &mut self, query: &[u32], change: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query to the new values in change, reporting via handler.Source§fn delete_links(
&mut self,
query: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn delete_links( &mut self, query: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query and reports each deletion via handler.Source§impl Links<u32> for &mut LinkStorage
doublets ships no blanket implementation for references, so decorating a
borrowed store (instead of moving it into the decorator) needs this
forwarding impl. It is what lets LinkStorage decorate itself for the
duration of a single operation.
impl Links<u32> for &mut LinkStorage
doublets ships no blanket implementation for references, so decorating a
borrowed store (instead of moving it into the decorator) needs this
forwarding impl. It is what lets LinkStorage decorate itself for the
duration of a single operation.
Source§fn constants(&self) -> &LinksConstants<u32>
fn constants(&self) -> &LinksConstants<u32>
LinksConstants (any/null/range values).Source§fn count_links(&self, query: &[u32]) -> u32
fn count_links(&self, query: &[u32]) -> u32
query.Source§fn create_links(
&mut self,
query: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn create_links( &mut self, query: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query and reports each creation via handler.Source§fn each_links(&self, query: &[u32], handler: ReadHandler<'_, u32>) -> Flow
fn each_links(&self, query: &[u32], handler: ReadHandler<'_, u32>) -> Flow
query, calling handler for each.Source§fn update_links(
&mut self,
query: &[u32],
change: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn update_links( &mut self, query: &[u32], change: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query to the new values in change, reporting via handler.Source§fn delete_links(
&mut self,
query: &[u32],
handler: WriteHandler<'_, u32>,
) -> Result<Flow, Error<u32>>
fn delete_links( &mut self, query: &[u32], handler: WriteHandler<'_, u32>, ) -> Result<Flow, Error<u32>>
query and reports each deletion via handler.Source§impl LinksStorage<u32> for LinkStorage
impl LinksStorage<u32> for LinkStorage
Source§fn create_link(&mut self, source: u32, target: u32) -> Result<u32, LinkError>
fn create_link(&mut self, source: u32, target: u32) -> Result<u32, LinkError>
Source§fn ensure_link_created(&mut self, index: u32) -> Result<u32, LinkError>
fn ensure_link_created(&mut self, index: u32) -> Result<u32, LinkError>
index, creating placeholders as needed.Source§fn get_link(&self, index: u32) -> Option<GenericLink<u32>>
fn get_link(&self, index: u32) -> Option<GenericLink<u32>>
index, if any.Source§fn link_exists(&self, index: u32) -> bool
fn link_exists(&self, index: u32) -> bool
true when a link exists at index.Source§fn update_link(
&mut self,
index: u32,
source: u32,
target: u32,
) -> Result<GenericLink<u32>, LinkError>
fn update_link( &mut self, index: u32, source: u32, target: u32, ) -> Result<GenericLink<u32>, LinkError>
index at source/target, returning the previous state.Source§fn delete_link(&mut self, index: u32) -> Result<GenericLink<u32>, LinkError>
fn delete_link(&mut self, index: u32) -> Result<GenericLink<u32>, LinkError>
index, returning the link that was removed.Source§fn update_link_observed(
&mut self,
index: u32,
source: u32,
target: u32,
observer: &mut dyn FnMut(GenericLink<u32>, GenericLink<u32>),
) -> Result<GenericLink<u32>, LinkError>
fn update_link_observed( &mut self, index: u32, source: u32, target: u32, observer: &mut dyn FnMut(GenericLink<u32>, GenericLink<u32>), ) -> Result<GenericLink<u32>, LinkError>
Source§fn delete_link_observed(
&mut self,
index: u32,
observer: &mut dyn FnMut(GenericLink<u32>, GenericLink<u32>),
) -> Result<GenericLink<u32>, LinkError>
fn delete_link_observed( &mut self, index: u32, observer: &mut dyn FnMut(GenericLink<u32>, GenericLink<u32>), ) -> Result<GenericLink<u32>, LinkError>
Source§fn query_links(
&self,
index: Option<u32>,
source: Option<u32>,
target: Option<u32>,
) -> Vec<GenericLink<u32>>
fn query_links( &self, index: Option<u32>, source: Option<u32>, target: Option<u32>, ) -> Vec<GenericLink<u32>>
Source§fn search_link(&self, source: u32, target: u32) -> Option<u32>
fn search_link(&self, source: u32, target: u32) -> Option<u32>
Source§fn get_or_create_link(
&mut self,
source: u32,
target: u32,
) -> Result<u32, LinkError>
fn get_or_create_link( &mut self, source: u32, target: u32, ) -> Result<u32, LinkError>
(source, target) link,
creating it when it does not exist yet.Source§fn has_external_changes(&self) -> Result<bool, LinkError>
fn has_external_changes(&self) -> Result<bool, LinkError>
Source§fn reload(&mut self) -> Result<(), LinkError>
fn reload(&mut self) -> Result<(), LinkError>
Source§fn links_count(&self) -> usize
fn links_count(&self) -> usize
Source§impl LinksStorageRef<u32> for LinkStorage
impl LinksStorageRef<u32> for LinkStorage
Source§impl NamedTypeLinks for LinkStorage
impl NamedTypeLinks for LinkStorage
fn create(&mut self, source: u32, target: u32) -> u32
fn ensure_created(&mut self, id: u32) -> u32
fn get_link(&mut self, id: u32) -> Option<Link>
fn exists(&mut self, id: u32) -> bool
fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>
fn delete(&mut self, id: u32) -> Result<Link>
Source§fn delete_observed(
&mut self,
id: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
Self::delete, reporting every change the deletion caused. Read morefn all_links(&mut self) -> Vec<Link> ⓘ
fn search(&mut self, source: u32, target: u32) -> Option<u32>
fn get_or_create(&mut self, source: u32, target: u32) -> u32
fn get_name(&mut self, id: u32) -> Result<Option<String>>
fn set_name(&mut self, id: u32, name: &str) -> Result<u32>
fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>
fn remove_name(&mut self, id: u32) -> Result<()>
fn save(&mut self) -> Result<()>
fn get_or_create_named(&mut self, name: &str) -> Result<u32>
fn try_ensure_created(&mut self, id: u32) -> Result<u32>
fn format_reference(&mut self, id: u32) -> Result<String>
fn format_lino(&mut self, link: &Link) -> Result<String>
fn lino_lines(&mut self) -> Result<Vec<String>>
fn write_lino_output<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
fn print_all_lino(&mut self) -> Result<()>
fn print_change_lino( &mut self, before: &Option<Link>, after: &Option<Link>, ) -> Result<()>
fn format_structure(&mut self, id: u32) -> Result<String>
fn format_structure_recursive( &mut self, id: u32, visited: &mut HashSet<u32>, ) -> Result<String>
Auto Trait Implementations§
impl Freeze for LinkStorage
impl RefUnwindSafe for LinkStorage
impl Send for LinkStorage
impl Sync for LinkStorage
impl Unpin for LinkStorage
impl UnsafeUnpin for LinkStorage
impl UnwindSafe for LinkStorage
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, L> DecoratorsExt<T> for Lwhere
T: LinkReference,
L: Doublets<T>,
impl<T, L> DecoratorsExt<T> for Lwhere
T: LinkReference,
L: Doublets<T>,
Source§fn with_uniqueness<P>(
self,
_policy: P,
) -> <P as UniquenessPolicy>::Decorator<T, Self>where
P: UniquenessPolicy,
fn with_uniqueness<P>(
self,
_policy: P,
) -> <P as UniquenessPolicy>::Decorator<T, Self>where
P: UniquenessPolicy,
Source§fn with_usages<P>(self, _policy: P) -> <P as UsagesPolicy>::Decorator<T, Self>where
P: UsagesPolicy,
fn with_usages<P>(self, _policy: P) -> <P as UsagesPolicy>::Decorator<T, Self>where
P: UsagesPolicy,
Source§fn with_usages_validation(self) -> UsagesValidator<T, Self>
fn with_usages_validation(self) -> UsagesValidator<T, Self>
UsagesValidator.Source§fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self>
fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self>
CascadeUsagesResolver.Source§fn with_inner_reference_existence_validation(
self,
) -> InnerReferenceExistenceValidator<T, Self>
fn with_inner_reference_existence_validation( self, ) -> InnerReferenceExistenceValidator<T, Self>
InnerReferenceExistenceValidator.Source§fn with_non_existent_dependencies_creation(
self,
) -> NonExistentDependenciesCreator<T, Self>
fn with_non_existent_dependencies_creation( self, ) -> NonExistentDependenciesCreator<T, Self>
NonExistentDependenciesCreator.Source§fn with_itself_constant_resolution(
self,
) -> ItselfConstantToSelfReferenceResolver<T, Self>
fn with_itself_constant_resolution( self, ) -> ItselfConstantToSelfReferenceResolver<T, Self>
ItselfConstantToSelfReferenceResolver.Source§fn with_null_constant_resolution(
self,
) -> NullConstantToSelfReferenceResolver<T, Self>
fn with_null_constant_resolution( self, ) -> NullConstantToSelfReferenceResolver<T, Self>
NullConstantToSelfReferenceResolver.Source§fn with_non_null_contents_deletion_resolution(
self,
) -> NonNullContentsLinkDeletionResolver<T, Self>
fn with_non_null_contents_deletion_resolution( self, ) -> NonNullContentsLinkDeletionResolver<T, Self>
NonNullContentsLinkDeletionResolver.Source§fn with_logging<W>(self, writer: W) -> LoggingDecorator<T, Self, W>
fn with_logging<W>(self, writer: W) -> LoggingDecorator<T, Self, W>
LoggingDecorator, logging every mutation to writer.Source§fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self>
fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self>
NoExceptionsDecorator.Source§fn with_automatic_uniqueness_and_usages_resolution(
self,
) -> CascadeUniquenessAndUsagesResolver<T, NonNullContentsLinkDeletionResolver<T, CascadeUsagesResolver<T, Self>>>
fn with_automatic_uniqueness_and_usages_resolution( self, ) -> CascadeUniquenessAndUsagesResolver<T, NonNullContentsLinkDeletionResolver<T, CascadeUsagesResolver<T, Self>>>
ILinksExtensions.DecorateWithAutomaticUniquenessAndUsagesResolution:
CascadeUsagesResolver innermost, then NonNullContentsLinkDeletionResolver,
then CascadeUniquenessAndUsagesResolver outermost.Source§impl<T, All> DoubletsExt<T> for Allwhere
T: LinkReference,
All: Doublets<T>,
impl<T, All> DoubletsExt<T> for Allwhere
T: LinkReference,
All: Doublets<T>,
Source§fn iter(
&self,
) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
fn iter( &self, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
Source§fn each_iter(
&self,
query: impl ToQuery<T>,
) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
fn each_iter( &self, query: impl ToQuery<T>, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator
query.