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 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
Sourcepub fn ensure_created(&mut self, id: u32) -> u32
pub fn ensure_created(&mut self, id: u32) -> u32
Creates a link with a specific ID, ensuring all links up to that ID exist
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
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
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
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 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>
fn 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
Mutably borrows from an owned value. Read more