Skip to content

Class BinaryProperty

Namespace: Void.Minecraft.Network.Registries.Transformations.Properties
Assembly: Void.Minecraft.dll

Represents unframed binary packet data.

public record BinaryProperty : IPacketProperty<BinaryProperty>, IPacketProperty, IEquatable<BinaryProperty>

Inheritance

objectBinaryProperty

Implements

IPacketProperty<BinaryProperty>, IPacketProperty, IEquatable<BinaryProperty>

Inherited Members

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

Constructors

BinaryProperty(ReadOnlyMemory<byte>)

Represents unframed binary packet data.

public BinaryProperty(ReadOnlyMemory<byte> Value)

Parameters

Value ReadOnlyMemory<byte>

The binary bytes, retained without copying.

Properties

AsSpan

Gets a read-only span over the current property memory.

public ReadOnlySpan<byte> AsSpan { get; }

Property Value

ReadOnlySpan<byte>

Value

The binary bytes, retained without copying.

public ReadOnlyMemory<byte> Value { get; init; }

Property Value

ReadOnlyMemory<byte>

Methods

FromStream(MemoryStream)

Creates a property over the complete contents of a memory stream without changing its position.

public static BinaryProperty FromStream(MemoryStream value)

Parameters

value MemoryStream

The source memory stream.

Returns

BinaryProperty

A property that aliases the stream buffer when it is publicly visible; otherwise, a property backed by a copy.

Read(ref MinecraftBuffer)

Consumes every remaining byte in a buffer and copies it into a binary property.

public static BinaryProperty Read(ref MinecraftBuffer buffer)

Parameters

buffer MinecraftBuffer

The source buffer, advanced to its end.

Returns

BinaryProperty

A property backed by a new byte array.

Write(ref MinecraftBuffer)

Writes the property’s binary value to the current position of the specified buffer.

public void Write(ref MinecraftBuffer buffer)

Parameters

buffer MinecraftBuffer

The writable buffer that receives the value.

Remarks

The bytes are written verbatim without a length prefix, and the buffer position advances by . An empty value writes no bytes.

Exceptions

ReadOnlyException

The buffer is backed by read-only storage.

InternalBufferOverflowException

The writable span backing the buffer has insufficient remaining capacity.