# 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.

- Kind: struct
- Namespace: `Sandbox`
- Assembly: `Sandbox.System`
- Modifiers: sealed

## Properties

- [`Length`](/api/Sandbox.ByteStream/Length): The total size of the data
- [`Position`](/api/Sandbox.ByteStream/Position): The current read or write position. Values are clamped to valid range.
- [`ReadRemaining`](/api/Sandbox.ByteStream/ReadRemaining)
- [`Writable`](/api/Sandbox.ByteStream/Writable): Is this stream writable?

## Methods

- [`Compress`](/api/Sandbox.ByteStream/Compress)
- [`Create`](/api/Sandbox.ByteStream/Create): Create a writable byte stream
- [`CreateReader`](/api/Sandbox.ByteStream/CreateReader)
- [`Decompress`](/api/Sandbox.ByteStream/Decompress)
- [`Dispose`](/api/Sandbox.ByteStream/Dispose)
- [`EnsureCanRead`](/api/Sandbox.ByteStream/EnsureCanRead): Validates read bounds with overflow protection
- [`EnsureCanWrite`](/api/Sandbox.ByteStream/EnsureCanWrite): Ensures buffer can accommodate write with overflow protection
- [`Read`](/api/Sandbox.ByteStream/Read): Reads an unmanaged type
- [`ReadArray`](/api/Sandbox.ByteStream/ReadArray): Returns an array of unmanaged types
- [`ReadObject`](/api/Sandbox.ByteStream/ReadObject)
- [`ToArray`](/api/Sandbox.ByteStream/ToArray): Get the data as an array of bytes
- [`TryRead`](/api/Sandbox.ByteStream/TryRead): Try to read variable, return false if not enough data
- [`Write`](/api/Sandbox.ByteStream/Write)
- [`WriteArray`](/api/Sandbox.ByteStream/WriteArray)
