Unit.Bandwidth (Hyper v0.1.0)

Copy Markdown View Source

A throughput, stored canonically in bytes per second. Build with bps/1 or the binary-prefix constructors (kibps/1, mibps/1, gibps/1, tibps/1); read back with as_bytes_per_sec/1. Arithmetic (+, -) and comparison (<, >, <=, >=) come from Unit.Operators.

Summary

Functions

Parse a string like "1GiBps". Suffixes: Bps/KiBps/MiBps/GiBps/TiBps.

Like parse/1 but raises ArgumentError on bad input.

The zero throughput (additive identity).

Types

t()

@opaque t()

Functions

as_bytes_per_sec(bandwidth)

@spec as_bytes_per_sec(t()) :: integer()

bps(v)

@spec bps(integer()) :: t()

gibps(v)

@spec gibps(integer()) :: t()

kibps(v)

@spec kibps(integer()) :: t()

mibps(v)

@spec mibps(integer()) :: t()

parse(s)

@spec parse(String.t()) :: {:ok, t()} | {:error, {:bad_unit, String.t()}}

Parse a string like "1GiBps". Suffixes: Bps/KiBps/MiBps/GiBps/TiBps.

parse!(s)

@spec parse!(String.t()) :: t()

Like parse/1 but raises ArgumentError on bad input.

tibps(v)

@spec tibps(integer()) :: t()

zero()

@spec zero() :: t()

The zero throughput (additive identity).