Table of Contents

Class LinksOperation<T>

Namespace
Foundation.Data.Doublets.Cli.Protocol
Assembly
Foundation.Data.Doublets.Cli.dll

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.

RequestReply
(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

A reply listing changes, one (before) (after) line each.

public static IReadOnlyList<Link<string>> ChangesDocument(IEnumerable<(Link<T> Before, Link<T> After)> changes)

Parameters

changes IEnumerable<(Link<T> Before, Link<T> After)>

Returns

IReadOnlyList<Link<string>>

Runs the operation against links and returns the reply document.

public IReadOnlyList<Link<string>> Execute(INamedTypesLinks<T> links)

Parameters

links INamedTypesLinks<T>

Returns

IReadOnlyList<Link<string>>

Exceptions

ArgumentException

An update or delete names a link that does not exist.

Recognises an operation request; null for any other document, such as a substitution query.

public static LinksOperation<T>? FromDocument(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

LinksOperation<T>

Exceptions

LinoProtocolException

The document names an operation but its argument is malformed.

(index: source target) with plain numbers.

public static Link<string> LinkLino(Link<T> link)

Parameters

link Link<T>

Returns

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

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<(Link<T> Before, Link<T> After)>

The count of a (count: N) reply.

public static T ParseCount(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

T

The link of a set-name or get-by-name reply, or null.

public static T? ParseLinkReply(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

T?

The links of an each reply.

public static IReadOnlyList<Link<T>> ParseLinks(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<Link<T>>

The name of a get-name reply, or null.

public static string? ParseName(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

string

ToDocument()

The request document for this operation.

public IReadOnlyList<Link<string>> ToDocument()

Returns

IReadOnlyList<Link<string>>