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//! - `cache_links` - A store as a cache: links that expire and bounded capacity
33//! - `remap_links` - A network under other addresses: an offset or a table
34//! - `external_ids` - The ids of other systems (UUIDs, URLs) bound to links
35//! - `graphql` - A Hasura-compatible GraphQL server for the Deep standard
36//! - `cli` - Argument parsing, so a custom tool can accept the same options
37//!
38//! # Extending
39//!
40//! [`NamedTypeLinks`] is the seam: every layer of the stack is written against
41//! it, and every decorator both implements it and wraps another implementation
42//! of it. A layer of your own -- a cache, an access check, a remote store --
43//! implements the trait and slots in anywhere, including under
44//! [`QueryProcessor`], which never learns what is beneath it.
45
46pub mod cache_links;
47pub mod changes_simplifier;
48pub mod cli;
49mod diagnostics;
50pub mod engine;
51pub mod error;
52pub mod external_ids;
53pub mod graphql;
54pub mod hybrid_reference;
55pub mod indexed_links;
56pub mod link;
57pub mod link_reference_validator;
58pub mod link_storage;
59pub mod link_storage_doublets;
60pub mod lino_database_input;
61pub mod lino_link;
62pub mod named_links;
63pub mod named_type_links;
64pub mod named_types;
65pub mod parser;
66pub mod permissions;
67pub mod persistent_transformations;
68pub mod pinned_types;
69pub mod protocol;
70pub mod query_address;
71pub mod query_options;
72mod query_parser;
73pub mod query_processor;
74pub mod query_processor_substitution;
75mod query_reply_budget;
76pub mod query_types;
77pub mod remap_links;
78pub mod sequences;
79pub mod storage;
80#[cfg(not(target_arch = "wasm32"))]
81pub mod store_lock;
82mod structure_format;
83mod text_storage_format;
84pub mod transactions;
85pub mod triplets;
86pub mod types;
87pub mod undoable_links;
88pub mod unicode_string_storage;
89pub mod union_links;
90pub mod version_control;
91
92/// The `doublets` crate this library is built on, re-exported so
93/// downstream crates can name upstream types (stores, decorators,
94/// `LinkReference` implementations) without adding their own dependency
95/// and risking a version mismatch.
96pub use doublets;
97
98// Re-export main types for easy access
99pub use cache_links::{CacheLinks, CacheOptions};
100pub use changes_simplifier::simplify_changes;
101pub use error::LinkError;
102pub use external_ids::{LinksExternalIds, EXTERNAL_ID_NAME};
103pub use hybrid_reference::{external_reference, external_reference_value, HybridReference};
104pub use indexed_links::IndexedLinksDecorator;
105pub use link::{DoubletsLink, GenericLink, Link};
106pub use link_storage::LinkStorage;
107pub use link_storage_doublets::link_storage_constants;
108pub use lino_database_input::{import_lino_file, import_lino_text};
109pub use lino_link::LinoLink;
110pub use named_links::NamedLinks;
111pub use named_type_links::NamedTypeLinks;
112pub use named_types::{NamedTypes, NamedTypesDecorator};
113pub use parser::Parser;
114pub use permissions::{
115    AccessPolicy, Forbidden, LinksTokenTable, PermissionAccess, PermissionMarkers,
116    PermissionPolicy, PermissionsDecorator,
117};
118pub use persistent_transformations::{
119    make_triggers_database_filename, PersistentTransformation, PersistentTransformationDecorator,
120    PersistentTransformationKind, PersistentTransformationQuery, TriggerStore,
121    INTERNAL_NAME_PREFIX,
122};
123pub use pinned_types::{PinnedTypes, PinnedTypesAccess, PinnedTypesDecorator};
124pub use protocol::{
125    BinaryLinoOptions, BinaryLinoProtocol, LinksClient, LinksServer, LinoProtocol, TextLinoProtocol,
126};
127pub use query_address::QueryAddress;
128pub use query_options::QueryOptions;
129pub use query_processor::{Changes, GenericQueryProcessor, QueryProcessor};
130pub use remap_links::{AddressMap, AddressTable, OffsetAddressMap, RemapLinks};
131pub use storage::{
132    decorators, lock_file_path, DoubletsStorage, FileLock, FileMappedUnitStore, FileMappedValue,
133    LinksStorage, LinksStorageRef, LockMode, MappedFlush, NamedLinksStorage, PersistentFileMapped,
134    ResolvedFileMappedUnitStore, StorageRevision,
135};
136pub use transactions::{
137    import_links_journal, is_links_journal, make_legacy_transitions_filename,
138    make_transitions_log_filename, open_transitions_journal, CommitMode, DoubletLink,
139    FileTransactionsDecorator, FileTransitionLog, GenericDoubletLink, GenericTransactionsDecorator,
140    GenericTransition, LogRetentionPolicy, ReplaceableTransitionLogStore, RowUndoPolicy,
141    TransactionHandle, TransactionsDecorator, Transition, TransitionKind, TransitionLogStore,
142};
143pub use triplets::{
144    import_triplets_lino, process_triplets_query, triplets_to_lino, DoubletRole, Triplet,
145    TripletChange, TripletMarkers, TripletQuery, Triplets, TripletsOverDoublets,
146    NOTHING_MARKER_NAME, PAIR_MARKER_NAME,
147};
148pub use types::{ensure_point, TypeMarkers, Types, TypesDecorator, EXTENDS_NAME, ROOT_TYPE_NAME};
149pub use undoable_links::{LinkChange, LinksUndoLog, UndoableLinksDecorator};
150pub use unicode_string_storage::UnicodeStringStorage;
151pub use union_links::{UnionLinks, UnionMember};
152pub use version_control::{
153    BranchInfo, FileVersionControlDecorator, GenericVersionControlDecorator,
154    VersionControlDecorator, DEFAULT_BRANCH_NAME,
155};