API ReferenceSandbox
ByteStreamclass
Write and read bytes to a stream. This aims to be as allocation free as possible while also being as fast as possible.
object→ByteStream
Methods25
Showing 25 methods
public Sandbox.ByteStream Compress(System.IO.Compression.CompressionLevel compressionLevel = 0)
| Parameter | Type | Description |
|---|---|---|
| compressionLevel = 0 | CompressionLevel | — |
public static Sandbox.ByteStream Create(int size)
Create a writable byte stream
| Parameter | Type | Description |
|---|---|---|
| size | int | — |
public static Sandbox.ByteStream CreateReader(System.ReadOnlySpan`1<byte> data)
| Parameter | Type | Description |
|---|---|---|
| data | ReadOnlySpan<byte> | — |
public Sandbox.ByteStream Decompress()
public void Dispose()
Returns:
void—public void EnsureCanRead(int size)
Validates read bounds with overflow protection
| Parameter | Type | Description |
|---|---|---|
| size | int | — |
Returns:
void—public void EnsureCanWrite(int size)
Ensures buffer can accommodate write with overflow protection
| Parameter | Type | Description |
|---|---|---|
| size | int | — |
Returns:
void—public T[] ReadArray(int maxElements = 1073741823)
Returns an array of unmanaged types
| Parameter | Type | Description |
|---|---|---|
| maxElements = 1073741823 | int | — |
Returns:
T[]—public object ReadObject(System.Type objectType)
| Parameter | Type | Description |
|---|---|---|
| objectType | Type | — |
Returns:
object—public byte[] ToArray()
Get the data as an array of bytes
Returns:
byte[]—public bool TryRead(T v)
Try to read variable, return false if not enough data
| Parameter | Type | Description |
|---|---|---|
| v | T | — |
Returns:
bool—No results match this filter.
Properties4
Showing 4 properties
public int Sandbox.ByteStream.Length { get; set; }
The total size of the data
Returns:
int—public int Sandbox.ByteStream.Position { get; set; }
The current read or write position. Values are clamped to valid range.
Returns:
int—public int Sandbox.ByteStream.ReadRemaining { get; set; }
Returns:
int—public bool Sandbox.ByteStream.Writable { get; set; }
Is this stream writable?
Returns:
bool—No results match this filter.