s&box docs

public sealed struct Sandbox.ByteStream

Write and read bytes to a stream. This aims to be as allocation free as possible while also being as fast as possible.

Broader workflow and conceptual references connected to this API.

Methods

Showing 25 methods

public Sandbox.ByteStream Compress(System.IO.Compression.CompressionLevel compressionLevel = 0)

Parameters

  • compressionLevel: Default: 0

public static Sandbox.ByteStream Create(int size)

Create a writable byte stream

public static Sandbox.ByteStream CreateReader(System.ReadOnlySpan`1<byte> data)

public void Dispose()

public void EnsureCanRead(int size)

Validates read bounds with overflow protection

public void EnsureCanWrite(int size)

Ensures buffer can accommodate write with overflow protection

public T[] ReadArray(int maxElements = 1073741823)

Returns an array of unmanaged types

Parameters

  • maxElements: Default: 1073741823

public object ReadObject(System.Type objectType)

public byte[] ToArray()

Get the data as an array of bytes

public bool TryRead(T v)

Try to read variable, return false if not enough data

Properties

Showing 4 properties

public int Sandbox.ByteStream.Position { get; set; }

The current read or write position. Values are clamped to valid range.

public int Sandbox.ByteStream.ReadRemaining { get; set; }

public bool Sandbox.ByteStream.Writable { get; set; }

Is this stream writable?

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.System
Doc IDT:Sandbox.ByteStream

On this page

Methodspublic Sandbox.ByteStream Compress(System.IO.Compression.CompressionLevel compressionLevel = 0)public static Sandbox.ByteStream Create(System.Int32 size)public static Sandbox.ByteStream CreateReader(System.ReadOnlySpan`1<System.Byte> data)public Sandbox.ByteStream Decompress()public System.Void Dispose()public System.Void EnsureCanRead(System.Int32 size)public System.Void EnsureCanWrite(System.Int32 size)public System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)public System.Int32 Read(System.Span`1<System.Byte> buffer)public T Read()public T Read(T defaultValue = null, System.Boolean unused = False)public System.String Read(System.String defaultValue)public T[] ReadArray(System.Int32 maxElements = 1073741823)public System.Object ReadObject(System.Type objectType)public System.Byte[] ToArray()public System.Boolean TryRead(T v)public System.Void Write(Sandbox.ByteStream stream, System.Int32 offset, System.Int32 maxSize)public System.Void Write(Sandbox.ByteStream stream)public System.Void Write(System.Byte[] rawData, System.Int32 offset, System.Int32 bytes)public System.Void Write(System.Byte[] rawData)public System.Void Write(System.String str)public System.Void Write(T data, System.Boolean unused = False)public System.Void Write(T value)public System.Void WriteArray(T[] arr, System.Boolean includeCount = True)public System.Void WriteArray(System.ReadOnlySpan`1<T> arr)Propertiespublic System.Int32 Sandbox.ByteStream.Length { get; set; }public System.Int32 Sandbox.ByteStream.Position { get; set; }public System.Int32 Sandbox.ByteStream.ReadRemaining { get; set; }public System.Boolean Sandbox.ByteStream.Writable { get; set; }Metadata