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