BinaryWriter
sealed class BinaryWriterimport BinaryWriter from Wax;A growable byte buffer with an explicit byte order and cursor. Numeric writes preserve bit
patterns, including floating-point values. Seeking past the end does not extend the buffer until
a write; extension fills gaps with zero bytes. ToArray returns a separate snapshot.
import BinaryWriter from Wax;
import BinaryReader from Wax;
api fn Main() : int32 {
var writer = new BinaryWriter.BigEndian();
writer.Write<uint16>(513u);
var bytes = writer.ToArray();
var reader = new BinaryReader.BigEndian(bytes);
return reader.Read<uint16>() as int32;
}
Inherits from object. Follow these links for inherited members.
Members
LittleEndianconstructor
public constructor LittleEndian ()Creates a little-endian cursor at byte position zero.
BigEndianconstructor
public constructor BigEndian ()Creates a big-endian cursor at byte position zero.
positiongetter
public get position() : int32The current zero-based byte offset.
lengthgetter
public get length() : int32The number of bytes in the backing data.
Seekmethod
public fn Seek(int32 offset) : voidSets an absolute byte offset, clamping negative offsets to zero. A position past length is
allowed and does not itself allocate.
Skipmethod
public fn Skip(int32 count) : voidMoves by a signed byte count. Positions below zero clamp to zero; positions above the signed 32-bit limit panic. Does not itself extend the buffer.
Resetmethod
public fn Reset() : voidMoves the cursor to byte zero without clearing or changing the backing data.
EnsureLengthmethod
public fn EnsureLength(int32 required) : voidExtends the written length to at least required bytes, growing storage and zero-filling newly exposed bytes. Does not move the cursor or shrink existing data.
EnsureSizemethod
public fn EnsureSize(int32 needed) : voidEnsures that needed bytes fit after the current cursor, extending the written length and zero-filling gaps as necessary. Does not move the cursor. Supply a nonnegative needed count; resulting length overflow panics.
Writemethod
public fn Write<T>(T value) : void where T is numericWrites sizeof(T) bytes at the cursor and advances it. Overwrites existing bytes or grows
the buffer, zero-filling any gap. A resulting length above the signed 32-bit limit panics.
WriteAtmethod
public fn WriteAt<T>(int32 offset, T value) : void where T is numericWrites a numeric value at an absolute offset without moving the cursor. Extends and zero-fills as needed. Negative offsets or an overflowing resulting length panic.
ToArraymethod
public fn ToArray() : uint8[]Copies all written bytes, including any zero-filled gaps, into an independent byte array. The cursor position does not limit the copy.