Thing/packages/GameCult.Thing.Contract/Keys.cs
Meta Vens 33eed442c7 GameCult.Thing.Contract: the gamecult.thing.* wire types for .NET, every door through a validating constructor
One C# type per Rust type, keys in the crate's slot order. Unions are abstract classes with an
internal constructor and sealed arms; unit arms are shared instances. ThingDomain owns the four
domains and ThingKeys the key grammar. CommandResult is built by four factories only; its
constructor is private. Builds against CultLib b3bd8dd5 through CultLibRoot. Tests follow in the
next commit; this one builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 08:37:04 +02:00

25 lines
1.3 KiB
C#

using System.Globalization;
namespace GameCult.Thing.Contract;
/// <summary>
/// The record key of each kind. Each key joins free-string provider or publisher ids (dotted, as the Verse names them)
/// with typed trailing parts: a segment holds no dot and a seq or version is digits, so a key splits at its last dot
/// (surface, asset catalog, result) or last two (composition), and two different field sets never build one key.
/// </summary>
public static class ThingKeys
{
public static string SurfaceKey(string providerId, string label) =>
$"thing:surface:{providerId}.{ThingDomain.Segment(label)}";
public static string CompositionKey(string publisher, string name, long version) =>
$"thing:composition:{publisher}.{ThingDomain.Segment(name)}.v{ThingDomain.Version(version).ToString(CultureInfo.InvariantCulture)}";
public static string InvocationKey(string invocationId) => $"thing:invocation:{invocationId}";
public static string ResultKey(string invocationId, int seq) =>
$"thing:result:{invocationId}.{ThingDomain.Seq(seq).ToString(CultureInfo.InvariantCulture)}";
public static string AssetCatalogKey(string providerId, string catalogId) =>
$"thing:asset_catalog:{providerId}.{ThingDomain.Segment(catalogId)}";
}