Class LinksOperation<T>
One call of the links interface (INamedTypesLinks<TLinkAddress>) as a LiNo document, so a store behind a LinksServer is used exactly like a local one through RemoteLinks.
public abstract record LinksOperation<T> : IEquatable<LinksOperation<T>> where T : struct, IBinaryInteger<T>, IUnsignedNumber<T>, IMinMaxValue<T>
Type Parameters
T
- Inheritance
-
LinksOperation<T>
- Implements
- Derived
- Inherited Members
Remarks
Every request is one top-level link named after the operation and holding exactly one value. The substitution
query language ignores that shape (a query needs a restriction and a substitution), so an operation
never collides with a query sent to the same server. The Rust LinksOperation<T> uses the same documents,
so clients and servers of both ports talk to each other.
| Request | Reply |
|---|---|
(count: (index source target)) | (count: N) |
(each: (index source target)) | one (index: source target) per match, ordered by index |
(create: (source target)) | () ((index: source target)) |
(update: (index source target)) | ((index: s t)) ((index: source target)) per change |
(delete: index) | ((index: source target)) () per removed link |
(get-name: link) | (name: 'text'), or nothing |
(set-name: (link 'text')) | (link: N) |
(get-by-name: 'text') | (link: N), or nothing |
(remove-name: link) | nothing |
Every reference in a reply is a number; failures are (error: 'message'). The changes of a
create, update or delete are the net change of every link it touched, the way
clink --changes reports a query: a cascading delete is one ((index: source target)) () per
removed link, without the intermediate steps by which the store behind the server got there.
Methods
ChangesDocument(IEnumerable<(Link<T> Before, Link<T> After)>)
A reply listing changes, one (before) (after) line each.
public static IReadOnlyList<Link<string>> ChangesDocument(IEnumerable<(Link<T> Before, Link<T> After)> changes)
Parameters
changesIEnumerable<(Link<T> Before, Link<T> After)>
Returns
- IReadOnlyList<Link<string>>
Execute(INamedTypesLinks<T>)
Runs the operation against links and returns the reply document.
public IReadOnlyList<Link<string>> Execute(INamedTypesLinks<T> links)
Parameters
linksINamedTypesLinks<T>
Returns
- IReadOnlyList<Link<string>>
Exceptions
- ArgumentException
An update or delete names a link that does not exist.
FromDocument(IReadOnlyList<Link<string>>)
Recognises an operation request; null for any other document, such as a substitution query.
public static LinksOperation<T>? FromDocument(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
Exceptions
- LinoProtocolException
The document names an operation but its argument is malformed.
LinkLino(Link<T>)
(index: source target) with plain numbers.
public static Link<string> LinkLino(Link<T> link)
Parameters
linkLink<T>
Returns
- Link<string>
ParseChanges(IReadOnlyList<Link<string>>)
The (before) (after) pairs of a create, update or delete reply; a missing side is
the null link.
public static IReadOnlyList<(Link<T> Before, Link<T> After)> ParseChanges(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- IReadOnlyList<(Link<T> Before, Link<T> After)>
ParseCount(IReadOnlyList<Link<string>>)
The count of a (count: N) reply.
public static T ParseCount(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- T
ParseLinkReply(IReadOnlyList<Link<string>>)
The link of a set-name or get-by-name reply, or null.
public static T? ParseLinkReply(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- T?
ParseLinks(IReadOnlyList<Link<string>>)
The links of an each reply.
public static IReadOnlyList<Link<T>> ParseLinks(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
- IReadOnlyList<Link<T>>
ParseName(IReadOnlyList<Link<string>>)
The name of a get-name reply, or null.
public static string? ParseName(IReadOnlyList<Link<string>> document)
Parameters
documentIReadOnlyList<Link<string>>
Returns
ToDocument()
The request document for this operation.
public IReadOnlyList<Link<string>> ToDocument()
Returns
- IReadOnlyList<Link<string>>