# avro.decoder

> A module of avro's API.

The Avro binary decoder.

A `Decoder` is a cursor over a `Span[UInt8]`: the primitive readers follow
the spec's binary encoding (zigzag varints, little-endian IEEE floats,
length-prefixed bytes, block-encoded arrays and maps), and `read_value`
drives them from a parsed `Schema`.

## Structs

### `Decoder`

```mojo
struct Decoder[origin: ImmOrigin]
```

A cursor over Avro binary data.

Implements: `Copyable`, `Movable`

Fields:

- `data: Span[UInt8, origin]`
- `pos: Int`

#### `__init__`

```mojo
def __init__(out self, data: Span[UInt8, origin])
```

```mojo
def __init__(out self, data: Span[UInt8, origin], pos: Int)
```

#### `remaining`

```mojo
def remaining(self) -> Int
```

#### `at_end`

```mojo
def at_end(self) -> Bool
```

#### `read_byte`

```mojo
def read_byte(mut self) -> UInt8
```

#### `read_boolean`

```mojo
def read_boolean(mut self) -> Bool
```

#### `read_long`

```mojo
def read_long(mut self) -> Int64
```

A zigzag-encoded variable-length integer.

#### `read_int`

```mojo
def read_int(mut self) -> Int32
```

#### `read_float`

```mojo
def read_float(mut self) -> Float32
```

#### `read_double`

```mojo
def read_double(mut self) -> Float64
```

#### `read_fixed`

```mojo
def read_fixed(mut self, n: Int) -> List[UInt8]
```

#### `read_bytes`

```mojo
def read_bytes(mut self) -> List[UInt8]
```

#### `read_string`

```mojo
def read_string(mut self) -> String
```

#### `skip`

```mojo
def skip(mut self, n: Int)
```

#### `read_block_count`

```mojo
def read_block_count(mut self) -> Int64
```

Read one array/map block header.

A negative count means the writer also wrote the block's byte size,
which is consumed here and discarded (it is only a skip hint).

#### `read_value`

```mojo
def read_value(mut self, schema: Schema) -> Value
```

Decode one datum described by `schema`'s root.

#### `read_value_at`

```mojo
def read_value_at(mut self, schema: Schema, i: Int) -> Value
```

#### `decode_into`

```mojo
def decode_into(mut self, schema: Schema, i: Int, mut arena: List[ValueNode]) -> Int
```

Decode node `i` straight into `arena`, returning its index.

The building block `avro.resolve` shares for the parts of a resolved
read that need no conversion.

#### `skip_value`

```mojo
def skip_value(mut self, schema: Schema, i: Int)
```

Advance past one datum without materialising it.
