# `Unit.Quantity`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/unit/quantity.ex#L1)

A one-dimensional physical quantity backed by a single canonical integer
(bytes, nanoseconds, bytes/sec, ...). Implementing this is all a unit type
needs to get `+`, `-`, and the ordering operators from `Unit.Operators`.

Implementations go through the type's own public constructor/accessor, so the
opaque struct is read and rebuilt without ever being poked from the outside.
Quantities are signed: subtraction may legitimately yield a negative value (a
deficit), and nothing clamps it.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `value`

```elixir
@spec value(t()) :: integer()
```

The canonical scalar (e.g. bytes) backing the quantity.

# `with_value`

```elixir
@spec with_value(t(), integer()) :: t()
```

A quantity of the same dimension as `quantity`, carrying scalar `n`.

`Unit.Operators` calls this to rebuild a result through the type's own public
constructor, so the opaque struct is never poked from the outside. `quantity`
only selects the implementation (the protocol dispatches on it); its scalar is
unused.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
