Every message that flows through a Terbin named pipe is encoded as aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/FarlandsModdingTeam/TerbinProyect/llms.txt
Use this file to discover all available pages before exploring further.
PacketRequest — a binary struct composed of a fixed-size Header for routing metadata, an IdArray that identifies the target action handler, and a variable-length byte[] payload. This page documents all three types, plus the ExceptionDTO struct used to transmit exception details over the wire.
Header
Header is an unmanaged, sequential struct ([StructLayout(LayoutKind.Sequential, Pack = 1)]) that carries the routing and control metadata for every packet. Its fixed layout ensures byte-perfect serialization without alignment padding.
Fields
Numeric identifier shared by a request and its matching response. Callers use this to correlate
Communicate() calls with their replies. If a value of 0 is passed to the constructor it is internally clamped to 1.Sequence number for fragment assembly.
0(TerbinProtocol.ORDER_SINGLE) — standalone, unfragmented packet.1— first fragment of a multi-part message.ushort.MaxValue(TerbinProtocol.FINAL_PACKET) — last fragment; triggers reassembly on the receiver.
Execution status code stamped into the header. Outbound packets typically use
CodeStatus.Execute; responses use CodeStatus.Succes, error codes (4xx / 5xx range), or control codes such as CodeStatus.IsCancelled.Identifies the remote memory slot used during fragment reassembly. Set to
CodeTerbinMemory.NotAsign for single-packet messages. Fragment upload packets carry the memory ID returned by SoliciteRequestMemory().Constructor
pIdRequest of 0 is silently promoted to 1.
IsSucces
Status == CodeStatus.Succes.
PacketRequest
PacketRequest is the top-level packet struct that is serialized and written to the pipe by StreamWriteStruct / read by StreamReadStruct. It implements IStructSerializable for binary round-tripping.
Fields
The routing and control header. Contains request ID, fragment order, status code, and memory slot ID.
The action routing key. On the receiver,
TerbinExecutor uses this byte sequence to look up the registered [TerbinExecutable] handler. A special value of new IdArray((byte)CodeTerbinProtocol.Response) marks the packet as a response rather than a new request.The data body of the packet. For fragmented transfers this is one chunk of the full message; after reassembly the merged bytes are placed back into
Payload before OnRecive fires.Constructor
Header(), IdArray(CodeTerbinProtocol.Response), []).
IsSucces
Head.IsSucces.
Static Factory Methods
CreateResponseError
HandleSendFragment() when the operation cannot proceed.
The request ID of the original failed request.
The error status to embed (e.g.,
CodeStatus.OverMaximunPacket, CodeStatus.NotFound).CreateResponseSucces
CreateResponse
IdMemory = NotAsign, OrderRequest = ORDER_SINGLE, and ActionMethod = CodeTerbinProtocol.Response. The lower-level primitive that the other factory methods delegate to.
IdArray
IdArray is a variable-length byte wrapper that serves as both the action routing key (the ActionMethod field of PacketRequest) and the handler registration key for [TerbinExecutable] attributes. It implements IEquatable<IEnumerable<byte>> so it works seamlessly as a dictionary key.
The maximum length of an
IdArray is 255 bytes (byte.MaxValue). Attempting to create or grow one beyond this limit throws OverflowException.Constructor
IdArray from a variable list of byte literals or cast enum values.
params object[] and uses Serialineitor.CastToByte to convert each element, enabling direct use of enums without an explicit cast:
Indexer
Implicit Conversions
| From | To | Description |
|---|---|---|
byte[] | IdArray | Wrap a raw byte array |
ByteArrayKey | IdArray | Convert from a dictionary key wrapper |
IdArray | ByteArrayKey | Convert to a dictionary key wrapper |
IdArray | byte[] | Unwrap to raw bytes |
Equality
TwoIdArray values are equal if and only if their underlying byte sequences are equal (SequenceEqual). GetHashCode() computes a stable polynomial hash over the bytes, making IdArray safe as a Dictionary<IdArray, …> key.
Key Collection Methods
| Method | Description |
|---|---|
Add(byte item) | Appends a byte, resizing the array. Throws OverflowException at 255. |
Remove(byte item) | Removes the first occurrence of a byte. |
Contains(byte item) | Returns true if the byte exists in the array. |
SetAction(params byte[] pActionMethod) | Replaces the entire underlying array. |
Clear() | Zeroes all elements (does not resize). |
CopyTo(byte[] array, int index) | Copies bytes into a destination array. |
ExceptionDTO
ExceptionDTO is a serializable struct used to transmit the details of a .NET exception across the pipe as a payload. It is sent with CodeStatus.Exception or CodeStatus.ExecutionException so the receiving end can log or display the error.
Fields
A developer-supplied label identifying where in the codebase the exception occurred (e.g.,
"PluginService>Install").Maps to
Exception.Message.Maps to
Exception.Source. Falls back to "N/A" when null.Maps to
Exception.InnerException?.Message. Falls back to "N/A" when null.Maps to
Exception.StackTrace. Falls back to "N/A" when null.Maps to
Exception.ToString() — the full formatted exception string including inner exceptions.Constructor
Building a Packet Manually
The example below constructs a completePacketRequest by hand, showing how all three core types compose together.
Sending an exception over the pipe
Sending an exception over the pipe