Skip to content

Struct AssetUid

Namespace: Apogee.Core.Assets
Assembly: Apogee.Core.dll

The identity of an asset that survives a rename or a move: 64 random bits. (zero) means "no UID" and is never minted. The text form is uid:// followed by 13 characters of lowercase Crockford base32 (0-9a-hjkmnp-tv-z), most significant digit first; the first digit holds the remaining 4 bits, so it is at most f.

public readonly record struct AssetUid : IEquatable<AssetUid>

Implements

IEquatable<AssetUid>

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

AssetUid(ulong)

The identity of an asset that survives a rename or a move: 64 random bits. (zero) means "no UID" and is never minted. The text form is uid:// followed by 13 characters of lowercase Crockford base32 (0-9a-hjkmnp-tv-z), most significant digit first; the first digit holds the remaining 4 bits, so it is at most f.

public AssetUid(ulong Value)

Parameters

Value ulong

The 64-bit value; zero is .

Fields

DigitCount

The number of base32 characters after the scheme.

public const int DigitCount = 13

Field Value

int

Scheme

The text that starts every UID: uid://.

public const string Scheme = "uid://"

Field Value

string

Properties

IsNone

Whether this is .

public bool IsNone { get; }

Property Value

bool

None

No UID (value zero).

public static AssetUid None { get; }

Property Value

AssetUid

Value

The 64-bit value; zero is .

public ulong Value { get; init; }

Property Value

ulong

Methods

New()

Mints a UID: 64 random bits from the system's cryptographic generator, never zero.

public static AssetUid New()

Returns

AssetUid

Parse(ReadOnlySpan<char>)

Reads the text form (see ).

public static AssetUid Parse(ReadOnlySpan<char> text)

Parameters

text ReadOnlySpan<char>

Returns

AssetUid

Exceptions

FormatException

The text is not a valid UID.

ToString()

The text form, uid:// and 13 base32 characters; gives the same form with all zeros, which refuses.

public override string ToString()

Returns

string

TryParse(ReadOnlySpan<char>, out AssetUid)

Reads the text form. Case does not matter. Fails on a missing scheme, a length other than 13 digits, a character outside the alphabet (i, l, o and u included), a first digit above f (it would not fit in 64 bits) and the value zero.

public static bool TryParse(ReadOnlySpan<char> text, out AssetUid uid)

Parameters

text ReadOnlySpan<char>

The text, with no surrounding spaces.

uid AssetUid

The UID, or on failure.

Returns

bool

Whether the text was a valid UID.