Table of Contents

Class MessageBinding<T>

Namespace
Typhon.Protocol
Assembly
Typhon.Protocol.dll

A ReplicatedMessageAttribute struct bound to the command the negotiated catalog declares under its name: every catalog field mapped to the struct field it comes from, so the struct encodes straight into a COMMANDS body — no name lookup, no value boxing, no allocation per send.

public sealed class MessageBinding<T> where T : unmanaged, IReplicatedMessage

Type Parameters

T

The command struct.

Inheritance
MessageBinding<T>
Inherited Members

Remarks

The catalog is the authority. The wire order, the codecs and the names are the server's: a builder call can rename a field or ignore one, and the struct cannot see that. So the binding is checked once, both ways, and refused whole with every mismatch listed (MessageBindingException): a catalog field the struct does not carry would travel as zero, and a struct field the catalog does not carry would be set by the caller and silently dropped. Either is the name-typo bug this path exists to remove, moved from a field name to a declaration — so neither is tolerated.

The bytes are the interpreter's. Every field goes through the same FieldCodec routines a RecordValues send uses, fed the widened value (MessageFieldValue): a float becomes a double and back without a bit changing, so an f32 field is written bit-exact.

Properties

MaxBytes

An upper bound of one encoded body, header excluded.

public int MaxBytes { get; }

Property Value

int

Plan

The command or event the struct is bound to.

public MessagePlan Plan { get; }

Property Value

MessagePlan

Methods

Bind(MessagePlan)

Binds T to plan.

public static MessageBinding<T> Bind(MessagePlan plan)

Parameters

plan MessagePlan

The command (or event) the catalog declares.

Returns

MessageBinding<T>

The binding.

Exceptions

MessageBindingException

The struct and the catalog disagree; the message lists every disagreement.

ToString()

public override string ToString()

Returns

string

WriteBody(ref WireWriter, in T, RealmFrame)

Encodes message's body — the fields, in the catalog's wire order.

public void WriteBody(ref WireWriter writer, in T message, RealmFrame frame = null)

Parameters

writer WireWriter

The writer.

message T

The struct.

frame RealmFrame

The realm frame a realm-framed field travels over; a scalar body never needs one.

Exceptions

ArgumentException

A value outside its codec's range, refused as a RecordValues send refuses it.