Cooper.Literals (Cooper v0.1.0)

Copy Markdown

Duration (CASC.md §6.8) and byte-size (§6.9) text parsing, shared between Cooper.Actions (the bare 500ms/512MiB literal forms) and Cooper.Resolver (the equivalent !duration("5m")/!bytes("512MiB") tagged-value forms, §7.5 -- "reachable ... for computed/interpolated values"). Same rules, same errors, one implementation.

Summary

Functions

Parses a byte-size literal's text into total bytes.

Parses a duration literal's text into total nanoseconds.

Functions

parse_bytes(text)

@spec parse_bytes(String.t()) :: {:ok, integer()} | {:error, String.t()}

Parses a byte-size literal's text into total bytes.

parse_duration(text)

@spec parse_duration(String.t()) :: {:ok, integer()} | {:error, String.t()}

Parses a duration literal's text into total nanoseconds.