.. rubric:: ``function spicy::zlib_init(window_bits: int64) : ZlibStream``
   :name: spicy_zlib_init

Initializes a zlib stream for decompression.

``window_bits``: Same as the corresponding parameter for zlib's `inflateInit2`
(see https://www.zlib.net/manual.html).

Will throw a `ZlibError` exception if initialization fails.

.. rubric:: ``function spicy::zlib_decompress(inout stream_: ZlibStream, data: bytes) : bytes``
   :name: spicy_zlib_decompress

Decompresses a chunk of data through the given zlib stream.

.. rubric:: ``function spicy::zlib_finish(inout stream_: ZlibStream) : bytes``
   :name: spicy_zlib_finish

Finalizes a zlib stream used for decompression.

.. rubric:: ``function spicy::base64_encode(inout stream_: Base64Stream, data: bytes) : bytes``
   :name: spicy_base64_encode

Encodes a stream of data into base64.

.. rubric:: ``function spicy::base64_decode(inout stream_: Base64Stream, data: bytes) : bytes``
   :name: spicy_base64_decode

Decodes a stream of base64 data back into the clear.

.. rubric:: ``function spicy::base64_finish(inout stream_: Base64Stream) : bytes``
   :name: spicy_base64_finish

Finalizes a base64 stream used for decoding or encoding.

.. rubric:: ``function spicy::crc32_init() : uint64``
   :name: spicy_crc32_init

Returns the initialization value for CRC32 computation.

.. rubric:: ``function spicy::crc32_add(crc: uint64, data: bytes) : uint64``
   :name: spicy_crc32_add

Computes a running CRC32.

.. rubric:: ``function spicy::current_time() : time``
   :name: spicy_current_time

Returns the current wall clock time.

.. rubric:: ``function spicy::mktime(y: uint64, m: uint64, d: uint64, H: uint64, M: uint64, S: uint64) : time``
   :name: spicy_mktime

Constructs a time value from a tuple of broken-out elements specifying local time.

- *y*: year (1970-...)
- *m*: month (1-12)
- *d*: day (1-31)
- *H*: hour (0-23)
- *M*: minute (0-59)
- *S*: second (0-59)

.. rubric:: ``function spicy::bytes_to_hexstring(value: bytes) : string``
   :name: spicy_bytes_to_hexstring

Returns a bytes value rendered as a hex string.

.. rubric:: ``function spicy::bytes_to_mac(value: bytes) : string``
   :name: spicy_bytes_to_mac

Returns a bytes value rendered as a MAC address string (i.e., colon-separated hex bytes).

.. rubric:: ``function spicy::getenv(name: string) : optional<string>``
   :name: spicy_getenv

Returns the value of an environment variable, if set.

.. rubric:: ``function spicy::strftime(format: string, timestamp: time) : string``
   :name: spicy_strftime

Formats a time according to user-specified format string.

This function uses the currently active locale and timezone to format
values. Formatted strings cannot exceed 128 bytes.

The format string can contain format specifiers supported by POSIX strftime, see
https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html.

This function can raise ``InvalidArgument`` if the timestamp could not be
converted to local time or formatted.

.. rubric:: ``function spicy::strptime(buf: string, format: string) : time``
   :name: spicy_strptime

Parses time from a string.

This function uses the currently active locale and timezone to parse values.

The format string can contain format specifiers supported by POSIX strptime, see
https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html.

This function raises ``InvalidArgument`` if the string could not be parsed
with the given format string, or ``OutOfRange`` if the parsed time value cannot
be represented.

.. rubric:: ``function spicy::parse_address(s: string) : addr``
   :name: spicy_parse_address

Parses an address from a string. The address can be in standard IPv4 or IPv6
ASCII represententation. The function raises ``InvalidArgument`` if the string
could not be parsed.

.. rubric:: ``function spicy::parse_address(b: bytes) : addr``
   :name: spicy_parse_address_2

Parses an address from a bytes instance. The address can be in standard IPv4
or IPv6 ASCII represententation. The function raises ``InvalidArgument`` if the
string could not be parsed.

.. rubric:: ``function spicy::accept_input()``
   :name: spicy_accept_input

Reports a confirmation to the host application indicating that the parser
appears to be processing the expected input format. It's up to the host
application how to use this information.

.. rubric:: ``function spicy::decline_input(reason: string)``
   :name: spicy_decline_input

Reports a violation to the host application indicating that the parser
appears not to be processing the expected input format.  It's up to the
host application how to use this information.

Note that this does not automatically abort processing. If that's desired,
you need to trigger a parse error as well, e.g., by throwing an error,
`throw "<error message>"`.

reason: user-presentable description of why the input seems wrong

