Table of Contents

Class TripletsOperation

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

The triplets of a server in triplet mode (issue #152) as LiNo documents, so a store behind a LinksServer is used exactly like a local ITriplets<TLinkAddress> store through RemoteLinks.

public abstract record TripletsOperation : IEquatable<TripletsOperation>
Inheritance
TripletsOperation
Implements
Derived
Inherited Members

Remarks

(delete: i), (count: ()) and a substitution query read the same in both worlds, so the shape of a request cannot tell a triplet from a doublet. That is why triplets are a mode of the server, Triplets (clink --serve --triplets): a server without it answers exactly as it always did, and one with it reads every request as triplets.

RequestReply
(count: (index type from to))(count: N)
(each: (index type from to))one (index: type from to) per match
(create: (type from to))() ((index: type from to))
(create: (0 0 0))() ((index: index 0 0)), a point: a triplet that is its own type
(update: (index type from to))((index: t f t)) ((index: type from to))
(delete: index)((index: type from to)) () per removed triplet, index first
(subscribe: (index type from to))(subscription: N); later pushes of (notify: N) and its changes

get-name, set-name, get-by-name, remove-name, unsubscribe and auth are the same as without triplets (LinksOperation), and the empty request lists every triplet. Any other document is a substitution query over triplets (TripletsQueryProcessor); its reply names the references that have a name, like a query over doublets.

A restriction holds up to four parts, matched part by part: the parts it leaves out match anything, as does *; an empty from or to is 0. The wrappers and pairs that store a triplet in doublets never appear.

A reply or push in a binary format whose arity holds three references but not the five of (index: type from to), such as 2..3, carries every triplet as (index: (type from to)), which travels as one link of three references; see Pack(IReadOnlyList<Link<string>>, MessageFormat). Every parser here reads both forms.

Methods

The inverse of Pack(IReadOnlyList<Link<string>>, MessageFormat): the canonical text of a triplet reply does not depend on the format that carried it.

public static IReadOnlyList<Link<string>> Canonical(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<Link<string>>

ChangesDocument(IEnumerable<TripletChange<uint>>)

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

public static IReadOnlyList<Link<string>> ChangesDocument(IEnumerable<TripletChange<uint>> changes)

Parameters

changes IEnumerable<TripletChange<uint>>

Returns

IReadOnlyList<Link<string>>

Execute(ITriplets<uint>)

Runs the operation against triplets and returns the reply document.

public abstract IReadOnlyList<Link<string>> Execute(ITriplets<uint> triplets)

Parameters

triplets ITriplets<uint>

Returns

IReadOnlyList<Link<string>>

Answers one request of a server in triplet mode against triplets; failures produce an ErrorDocument(string). The counterpart of ExecuteRequest(INamedTypesLinks<uint>, IReadOnlyList<Link<string>>, bool).

public static IReadOnlyList<Link<string>> ExecuteRequest(ITriplets<uint> triplets, IReadOnlyList<Link<string>> document)

Parameters

triplets ITriplets<uint>
document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<Link<string>>

Recognises a triplet operation; null for any other document, such as a substitution query or a request about names.

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

Parameters

document IReadOnlyList<Link<string>>

Returns

TripletsOperation

Exceptions

LinoProtocolException

The document names an operation but its argument is malformed.

Matches(Triplet<uint>, LinksRestriction)

Whether triplet matches restriction, part by part.

public static bool Matches(Triplet<uint> triplet, LinksRestriction restriction)

Parameters

triplet Triplet<uint>
restriction LinksRestriction

Returns

bool

NotificationDocument(uint, IEnumerable<TripletChange<uint>>)

A push: (notify: N) followed by one (before) (after) line per change.

public static IReadOnlyList<Link<string>> NotificationDocument(uint subscription, IEnumerable<TripletChange<uint>> changes)

Parameters

subscription uint
changes IEnumerable<TripletChange<uint>>

Returns

IReadOnlyList<Link<string>>

Rewrites every triplet of document so it fits format: in a binary format whose arity holds three references but not five, (index: type from to) becomes (index: (type from to)), whose second part travels as one link of three references. Under any other format the document stays as it is.

public static IReadOnlyList<Link<string>> Pack(IReadOnlyList<Link<string>> document, MessageFormat format)

Parameters

document IReadOnlyList<Link<string>>
format MessageFormat

Returns

IReadOnlyList<Link<string>>

(index: type from to) needs a link of five references, the marker of a named link and the index included, so under 2..3 the mapping would spell it as a chain of doublets: nothing would gain from the arity.

The (before) (after) pairs of a create, update or delete reply.

public static IReadOnlyList<TripletChange<uint>> ParseChanges(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<TripletChange<uint>>

The subscription and the changes of a NotificationDocument(uint, IEnumerable<TripletChange<uint>>).

public static TripletsNotification ParseNotification(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

TripletsNotification

A triplet, as (index: type from to) or as Pack(IReadOnlyList<Link<string>>, MessageFormat) writes it.

public static Triplet<uint> ParseTriplet(Link<string> link)

Parameters

link Link<string>

Returns

Triplet<uint>

The triplets of an each reply.

public static IReadOnlyList<Triplet<uint>> ParseTriplets(IReadOnlyList<Link<string>> document)

Parameters

document IReadOnlyList<Link<string>>

Returns

IReadOnlyList<Triplet<uint>>

Query(LinksRestriction)

The query a restriction asks for; the parts it leaves out match anything.

public static TripletQuery<uint> Query(LinksRestriction restriction)

Parameters

restriction LinksRestriction

Returns

TripletQuery<uint>

RestrictionOf(TripletQuery<uint>)

The restriction of query, in the order of the wire.

public static LinksRestriction RestrictionOf(TripletQuery<uint> query)

Parameters

query TripletQuery<uint>

Returns

LinksRestriction

ToDocument()

The request document for this operation.

public IReadOnlyList<Link<string>> ToDocument()

Returns

IReadOnlyList<Link<string>>

TripletLino(Triplet<uint>)

(index: type from to) with plain numbers.

public static Link<string> TripletLino(Triplet<uint> triplet)

Parameters

triplet Triplet<uint>

Returns

Link<string>