# tuningfork::ByteStream

`#include <protobuf_nano_util.h>`

A view on the bytes provided in `vec`.

## Summary

`Write` will call `realloc` if more bytes are needed and it is up to the caller to free the data allocated.

It is valid to set `vec=nullptr` and `size=0`, in which case `vec` will be allocated using `malloc`.

| ### Public attributes ||
|---|---|
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/byte-stream#structtuningfork_1_1_byte_stream_1a159d32619752e228b81d56655c7ee282` | `size_t` The current position in the stream while decoding or encoding. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/byte-stream#structtuningfork_1_1_byte_stream_1a536a03d241504fcb8f5181266210d2f1` | `size_t` The size of the bytes that are pointed by `vec`. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/byte-stream#structtuningfork_1_1_byte_stream_1a3b0dcce6155aa29b4b392e0c42eb7fe0` | `uint8_t *` Pointer to the bytes represented by the stream. |

| ### Public static functions ||
|---|---|
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/byte-stream#structtuningfork_1_1_byte_stream_1a67f50312eac2f5428fc5ab73f97ebe1b(pb_istream_t *stream, uint8_t *buf, size_t count)` | `bool` Read `count` bytes from the stream to the given buffer. |
| `https://developer.android.com/games/sdk/reference/performance-tuner/custom-engine/struct/tuningfork/byte-stream#structtuningfork_1_1_byte_stream_1a8bc2a408637b36a0a25ca84d2f6b8592(pb_ostream_t *stream, const uint8_t *buf, size_t count)` | `bool` Write `count` bytes from the given buffer to the stream. |

## Public attributes

### it

```
size_t tuningfork::ByteStream::it
```
The current position in the stream while decoding or encoding.

### size

```
size_t tuningfork::ByteStream::size
```
The size of the bytes that are pointed by `vec`.

### vec

```
uint8_t * tuningfork::ByteStream::vec
```
Pointer to the bytes represented by the stream.

## Public static functions

### Read

```
bool tuningfork::ByteStream::Read(
  pb_istream_t *stream,
  uint8_t *buf,
  size_t count
)
```
Read `count` bytes from the stream to the given buffer.

<br />

Details Parameters `stream` The stream to read from. `buf` The buffer to write to. `count` The number of bytes to read. **Returns** true if successful, false on a read error.

### Write

```
bool tuningfork::ByteStream::Write(
  pb_ostream_t *stream,
  const uint8_t *buf,
  size_t count
)
```
Write `count` bytes from the given buffer to the stream.

<br />

Details Parameters `stream` The stream to write to. `buf` The buffer to read from. `count` The number of bytes to write. **Returns** true if successful, false on a write error.