# Keys

> USearch for Mojo

A key is 128 bits of opaque identity, rendered as a lowercase dashed UUID.
Keys need not be unique: several entries may share one, and `count` reports how many.

```mojo
var key = Key(integer=42)
print(key)                     # 00000000-0000-0000-0000-00000000002a
print(key.as_integer().value()) # 42
```

`from usearch import Key`

## Key

The sixteen opaque bytes naming one entry - `usearch_key_t`, in two words.

```mojo
struct Key
```

Mojo cannot put a `UInt8` array in a register-passable struct, and a 16-lane SIMD would take an
argument class the C ABI never gives a byte array, so the bytes cross as the two integers they
occupy. Keys need not be unique: several entries may share one, which is what `values_per_key`
and the late-interaction verb are for.

- `leading` `UInt64`: Bytes 0 through 7, zero for an integer identity.
- `trailing` `UInt64`: Bytes 8 through 15, holding an integer identity big-endian.

Conforms to: `Copyable`, `Deinitable`, `Equatable`, `ImplicitlyCopyable`, `Movable`, `RegisterPassable`, `TrivialRegisterPassable`, `Writable`

## __init__

Builds the key an integer identity names, with the leading bytes zeroed.

```mojo
def __init__(*, integer: UInt64) -> Self
```

- `integer`: The identity to park in bytes 8 through 15, most significant byte first.

## as_integer

The integer identity in bytes 8 through 15, and nothing when the leading ones are set.

```mojo
def as_integer(self) -> Optional[UInt64]
```

## write_to

Writes the key as the lowercase dashed UUID the C header calls canonical. Binding-only.

```mojo
def write_to(self, mut writer: T)
```

- `writer` (mut): The sink the key is appended to.

