Expand description
LiNo substitution operations over TCP/IP (issue #105).
Two interchangeable protocols carry LiNo documents between a client and a server:
TextLinoProtocol: UTF-8 LiNo text, each message ended by a line holding only.(SMTP-style dot-stuffing keeps the framing unambiguous).BinaryLinoProtocol: a self-delimitingLinksPacketof binary links notation, made of sections of links that share one reference width (1, 2, 4 or 8 bytes) and one arity range. By default every link is a doublet and the whole packet uses the narrowest width that fits; the options external references, arity (for example2..3or1..) and packed widths can be switched on one by one.
The binary links notation itself (packets, the LiNo mapping, the canonical
text form) comes from [links_notation::binary]; this module re-exports
it and adds the transport: message framing, the server, the client and the
store archive.
Both implement LinoProtocol, so a LinoConnection or a
LinksClient switches protocol by swapping one value. A
LinksServer detects the protocol of every message and answers in kind.
A request is a substitution query, so it covers create, read, update and
delete; the reply lists the (before) (after) changes, exactly like
clink --changes. The empty request reads the whole store.
use link_cli::protocol::{format_document, parse_document, BinaryLinoOptions, BinaryLinoProtocol};
let document = parse_document("() ((1 1))").unwrap();
let binary = BinaryLinoProtocol::with_options(
BinaryLinoOptions::default().with_external_references(true),
);
let bytes = binary.encode(&document).unwrap();
assert_eq!(binary.decode(&bytes).unwrap(), document);
assert_eq!(format_document(&document), "() ((1 1))");Re-exports§
pub use archive::export_store;pub use archive::export_store_file;pub use archive::import_store;pub use archive::import_store_file;pub use links_operations::GenericLinksOperation;pub use links_operations::LinksNotification;pub use links_operations::LinksOperation;pub use triplets_operations::execute_triplets_request;pub use triplets_operations::TripletsNotification;pub use triplets_operations::TripletsOperation;
Modules§
- archive
- Store archive: a whole links store in binary links notation.
- ipc
- Interchangeable inter-process communication transports (issue #140).
- links_
operations - The links interface (
ILinksin C#, [doublets::Links] in Rust) as LiNo documents, so a store behind aLinksServeris used exactly like a local one throughRemoteLinks. - packet
- Binary links notation: a self-delimiting packet of links.
- triplets_
operations - The triplets of a server in triplet mode (issue #152) as LiNo documents, so
a store behind a
LinksServeris used exactly like a localTripletsstore throughRemoteLinks.
Structs§
- Arity
Range - How many references the links of a section hold:
min..=max, wheremax = Nonemeans no upper bound. - Binary
Lino Options - Optional features of the binary LiNo protocol.
- Binary
Lino Protocol - Binary links packets of [
links_notation::binary]; every message is self-delimiting, so no extra framing is needed. - Decode
Limits - Safety limits applied while decoding untrusted input.
- Links
Client - Sends substitution queries to a LiNo server over any
LinoProtocol. - Links
Packet - A decoded binary links packet.
- Links
Server - A bound, not yet serving, LiNo server.
- Links
Sessions - A store served to many sessions, each with its subject (issue #149).
- Lino
Connection - A byte stream decorated with a
LinoProtocol. - Protocol
Limits - Limits applied to incoming messages of either protocol.
- Remote
Links - A links store served by a
LinksServer, usable wherever a local store is. - Section
- A run of links at consecutive addresses sharing an arity range and a reference width.
- Server
Options - Server configuration.
- Session
Id - A session of a
LinksSessions, asLinksSessions::openreturns it. - Shutdown
Handle - Stops a running
LinksServer::servefrom another thread. - Text
Lino Protocol - UTF-8 LiNo text, one message per block of lines ended by a line holding
only
.. Lines starting with.get one extra.(SMTP dot-stuffing).
Enums§
- Accepted
Protocols - Which protocols a server accepts.
- Binary
Error - A failure while encoding or decoding a packet or LiNo document.
- Message
Format - The wire format a message arrived in, so a reply can use the same one.
- Protocol
Error - Everything that can go wrong while encoding, decoding or exchanging a LiNo message.
- Reference
- One reference inside a packet.
Constants§
- DEFAULT_
MAX_ PENDING_ NOTIFICATIONS - The default of
ServerOptions::max_pending_notifications. - DEFAULT_
MAX_ TEXT_ BYTES - The default limit of a text message: 64 MiB.
Traits§
- Lino
Protocol - Reads and writes whole LiNo documents on a byte stream.
- Timed
Stream - A stream whose reads can time out, so a
LinoConnectionover it can wait for a message.
Functions§
- decode_
document - Converts a packet back into a document.
- encode_
document - Converts a document into a packet.
- encode_
document_ with_ limits - Converts a native model into a packet using caller-selected work budgets.
- error_
document - The reply document for a failed request:
(error: 'message'). - error_
message - Returns the message of an
(error: 'message')reply. - execute_
request - Executes one request against
storage. - execute_
request_ for - Executes an owned protocol document with the selected address type. Checked storage policies admit the document before recursive formatting.
- format_
document - Formats a document as canonical LiNo text, one top-level link per line.
- format_
link - Formats one link as it appears nested inside another link.
- format_
reference - Quotes a reference when it would not survive parsing as a bare word.
- is_
binary_ start - True when
bytestarts a binary message rather than a text one. - parse_
document - Parses LiNo text into a canonical document. Blank input is the empty document.
- parse_
document_ with_ limits - Parses bounded transport text before converting or formatting its document. The upstream grammar enforces depth before building its recursive model.
- query_
document - Carries the exact original query text, including quoted-reference kinds. Older peers must explicitly support this envelope before a client uses it.
- read_
any_ document - Reads one message in whichever protocol the peer used.
Type Aliases§
- Authenticator
- The subject of a token, or
Nonewhen the token is not valid: answers(auth: token). - Lino
Document - A LiNo document: the list of top-level links of a message.
- Protocol
Result - Result alias used throughout
crate::protocol. - Readable
- Which links a subscriber may see: see
LinksServer::with_readable.