Skip to main content

link_cli/
lib.rs

1//! Link CLI Library - Core functionality for links manipulation
2//!
3//! This library provides the core data structures and functionality
4//! for the link-cli tool, implementing a doublet storage system
5//! with LiNo notation support.
6//!
7//! # Modules
8//!
9//! Every module is public: `clink` is one front end over this library, and an
10//! application that needs a different one should be able to reach the same
11//! pieces rather than reimplement them.
12//!
13//! - `link` - The core Link data structure
14//! - `error` - Error types for link operations
15//! - `lino_link` - LiNo link representation
16//! - `parser` - LiNo notation parser
17//! - `link_storage` - Persistent link storage
18//! - `storage` - Reusable storage traits and the doublets-backed store
19//! - `changes_simplifier` - Changes simplification
20//! - `query_processor` - LiNo query processing
21//! - `query_types` - Patterns and resolved links, the shapes a query passes through
22//! - `link_reference_validator` - Checking, and optionally creating, referenced links
23//! - `named_type_links` - The storage interface every layer is written against
24//! - `named_types`, `pinned_types` - Named and pinned type decorators
25//! - `persistent_transformations` - Persistent transformation triggers
26//! - `permissions` - An optional permission layer with rules stored in links
27//! - `undoable_links` - Writes kept to be undone, so a failed request leaves nothing
28//! - `types` - A type hierarchy with sub-types and multiple inheritance
29//! - `triplets` - Triplets `(index: type from to)` stored in doublets, with substitution and LiNo
30//! - `transactions`, `version_control` - Reversible transitions, branches and tags
31//! - `union_links` - Many networks seen as one, the first member shadowing the rest
32//! - `remap_links` - A network under other addresses: an offset or a table
33//! - `external_ids` - The ids of other systems (UUIDs, URLs) bound to links
34//! - `cli` - Argument parsing, so a custom tool can accept the same options
35//!
36//! # Extending
37//!
38//! [`NamedTypeLinks`] is the seam: every layer of the stack is written against
39//! it, and every decorator both implements it and wraps another implementation
40//! of it. A layer of your own -- a cache, an access check, a remote store --
41//! implements the trait and slots in anywhere, including under
42//! [`QueryProcessor`], which never learns what is beneath it.
43
44pub mod changes_simplifier;
45pub mod cli;
46pub mod error;
47pub mod external_ids;
48pub mod hybrid_reference;
49pub mod indexed_links;
50pub mod link;
51pub mod link_reference_validator;
52pub mod link_storage;
53pub mod link_storage_doublets;
54pub mod lino_database_input;
55pub mod lino_link;
56pub mod named_links;
57pub mod named_type_links;
58pub mod named_types;
59pub mod parser;
60pub mod permissions;
61pub mod persistent_transformations;
62pub mod pinned_types;
63pub mod protocol;
64pub mod query_options;
65mod query_parser;
66pub mod query_processor;
67pub mod query_processor_substitution;
68pub mod query_types;
69pub mod remap_links;
70pub mod sequences;
71pub mod storage;
72pub mod transactions;
73pub mod triplets;
74pub mod types;
75pub mod undoable_links;
76pub mod unicode_string_storage;
77pub mod union_links;
78pub mod version_control;
79
80/// The `doublets` crate this library is built on, re-exported so
81/// downstream crates can name upstream types (stores, decorators,
82/// `LinkReference` implementations) without adding their own dependency
83/// and risking a version mismatch.
84pub use doublets;
85
86// Re-export main types for easy access
87pub use changes_simplifier::simplify_changes;
88pub use error::LinkError;
89pub use external_ids::{LinksExternalIds, EXTERNAL_ID_NAME};
90pub use hybrid_reference::{external_reference, external_reference_value, HybridReference};
91pub use indexed_links::IndexedLinksDecorator;
92pub use link::{DoubletsLink, GenericLink, Link};
93pub use link_storage::LinkStorage;
94pub use link_storage_doublets::link_storage_constants;
95pub use lino_database_input::{import_lino_file, import_lino_text};
96pub use lino_link::LinoLink;
97pub use named_links::NamedLinks;
98pub use named_type_links::NamedTypeLinks;
99pub use named_types::{NamedTypes, NamedTypesDecorator};
100pub use parser::Parser;
101pub use permissions::{
102    AccessPolicy, Forbidden, LinksTokenTable, PermissionAccess, PermissionMarkers,
103    PermissionPolicy, PermissionsDecorator,
104};
105pub use persistent_transformations::{
106    make_triggers_database_filename, PersistentTransformation, PersistentTransformationDecorator,
107    PersistentTransformationKind, PersistentTransformationQuery, TriggerStore,
108    INTERNAL_NAME_PREFIX,
109};
110pub use pinned_types::{PinnedTypes, PinnedTypesAccess, PinnedTypesDecorator};
111pub use protocol::{
112    BinaryLinoOptions, BinaryLinoProtocol, LinksClient, LinksServer, LinoProtocol, TextLinoProtocol,
113};
114pub use query_options::QueryOptions;
115pub use query_processor::{Changes, QueryProcessor};
116pub use remap_links::{AddressMap, AddressTable, OffsetAddressMap, RemapLinks};
117pub use storage::{
118    decorators, lock_file_path, DoubletsStorage, FileLock, FileMappedUnitStore, FileMappedValue,
119    LinksStorage, LinksStorageRef, LockMode, NamedLinksStorage, PersistentFileMapped,
120    ResolvedFileMappedUnitStore, StorageRevision,
121};
122pub use transactions::{
123    CommitMode, DoubletLink, FileTransitionLog, GenericDoubletLink, GenericTransactionsDecorator,
124    GenericTransition, LogRetentionPolicy, TransactionHandle, TransactionsDecorator, Transition,
125    TransitionKind, TransitionLogStore,
126};
127pub use triplets::{
128    import_triplets_lino, process_triplets_query, triplets_to_lino, DoubletRole, Triplet,
129    TripletChange, TripletMarkers, TripletQuery, Triplets, TripletsOverDoublets,
130    NOTHING_MARKER_NAME, PAIR_MARKER_NAME,
131};
132pub use types::{ensure_point, TypeMarkers, Types, TypesDecorator, EXTENDS_NAME, ROOT_TYPE_NAME};
133pub use undoable_links::{LinkChange, LinksUndoLog, UndoableLinksDecorator};
134pub use unicode_string_storage::UnicodeStringStorage;
135pub use union_links::{UnionLinks, UnionMember};
136pub use version_control::{BranchInfo, VersionControlDecorator, DEFAULT_BRANCH_NAME};