Interface IInlineUtf8Text
A fixed-capacity UTF-8 string that lives inside a message struct: what lets an event or a command carry a str.
public interface IInlineUtf8Text
Remarks
Why the text is inline rather than a reference. An event and a command both decode into an unmanaged
struct — the event arena is a memcpy of a fixed size under a per-worker gate, and a command decodes straight into the
struct the application reads. A string field would make both managed, so text that travels has to be
bytes the struct owns. The capacity is part of the type, which is why there is one type per capacity: C# cannot size
an inline buffer by a generic parameter.
The cost, stated. A message occupies its declared capacity whether the text is three bytes or all of it — a
Utf8Text256 is 258 bytes in the arena either way. The WIRE carries only the bytes that are used
(varu length | UTF-8), so this is a memory trade inside the server and never a bandwidth one.
Adding a capacity is a handful of lines: an InlineArrayAttribute buffer and a struct beside the ones here. Do it when something needs it rather than in advance.
Properties
Capacity
The largest number of UTF-8 bytes this type holds. Must equal the str codec's cap where it is declared.
public static abstract int Capacity { get; }
Property Value
Length
The bytes in use.
int Length { get; }