Unit.Information (Hyper v0.1.0)

Copy Markdown View Source

A quantity of data, stored canonically in bytes. Build with bytes/1 or the binary-prefix constructors (kib/1, mib/1, gib/1, tib/1); read back with the matching as_* accessor. Arithmetic (+, -) and comparison (<, >, <=, >=) come from Unit.Operators.

Summary

Functions

The quantity in whole 512-byte sectors.

Parse a string like "4GiB" into an Information. Suffixes: B/KiB/MiB/GiB/TiB.

Like parse/1 but raises ArgumentError on bad input.

v 512-byte disk sectors — the kernel's universal block-device unit.

The zero quantity (additive identity).

Types

t()

@opaque t()

Functions

as_bytes(information)

@spec as_bytes(t()) :: integer()

as_gib(information)

@spec as_gib(t()) :: integer()

as_mib(information)

@spec as_mib(t()) :: integer()

as_sectors(information)

@spec as_sectors(t()) :: integer()

The quantity in whole 512-byte sectors.

bytes(v)

@spec bytes(integer()) :: t()

gib(v)

@spec gib(integer()) :: t()

kib(v)

@spec kib(integer()) :: t()

mib(v)

@spec mib(integer()) :: t()

parse(s)

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

Parse a string like "4GiB" into an Information. Suffixes: B/KiB/MiB/GiB/TiB.

parse!(s)

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

Like parse/1 but raises ArgumentError on bad input.

sectors(v)

@spec sectors(integer()) :: t()

v 512-byte disk sectors — the kernel's universal block-device unit.

tib(v)

@spec tib(integer()) :: t()

zero()

@spec zero() :: t()

The zero quantity (additive identity).