5.3. Library¶
5.3.1. Module spicy
¶
5.3.1.1. Types¶
spicy::AddressFamily
Specifies an address’ IP family.
type AddressFamily = enum {
IPv4, # IP4 address
IPv6 # IPv6 address
};
spicy::Base64Stream
Captures the state of base64 encoding/decoding for the corresponding library functions.
spicy::BitOrder
Specifies the bit order for individual bit ranges inside a bitfield.
type BitOrder = enum {
LSB0, # bits are interpreted as lowest-significant-bit coming first
MSB0 # bits are interpreted as most-significant-bit coming first
};
spicy::ByteOrder
Specifies byte order for data operations.
type ByteOrder = enum {
Little, # data is in little-endian byte order
Big, # data is in big-endian byte order
Network, # data is in network byte order (same a big endian)
Host # data is in byte order of the host we are executing on
};
spicy::Charset
Specifies the character set for bytes encoding/decoding.
type Charset = enum {
ASCII,
UTF8
};
spicy::MatchState
Captures state for incremental regular expression matching.
spicy::Protocol
Specifies a transport-layer protocol.
type Protocol = enum {
TCP,
UDP,
ICMP
};
spicy::RealType
Specifies the type of a real value.
type RealType = enum {
IEEE754_Single, # single precision in IEEE754 format
IEEE754_Double # double precision in IEEE754 format
};
spicy::ReassemblerPolicy
Specifies the policy for a sink’s reassembler when encountering overlapping data.
type ReassemblerPolicy = enum {
First # take the original data & discard the new data
};
spicy::Side
Specifies a side an operation should operate on.
type Side = enum {
Left, # operate on left side
Right, # operate on right side
Both # operate on both sides
};
spicy::Direction
Specifies direction of a search.
type Direction = enum {
Forward, # search forward
Backward, # search backward
};
spicy::ZlibStream
Captures the state of gzip decompression for the corresponding library functions.
5.3.1.2. Functions¶
function spicy::zlib_init(window_bits: int64) : ZlibStream
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.
function spicy::zlib_decompress(inout stream_: ZlibStream, data: bytes) : bytes
Decompresses a chunk of data through the given zlib stream.
function spicy::zlib_finish(inout stream_: ZlibStream) : bytes
Finalizes a zlib stream used for decompression.
function spicy::base64_encode(inout stream_: Base64Stream, data: bytes) : bytes
Encodes a stream of data into base64.
function spicy::base64_decode(inout stream_: Base64Stream, data: bytes) : bytes
Decodes a stream of base64 data back into the clear.
function spicy::base64_finish(inout stream_: Base64Stream) : bytes
Finalizes a base64 stream used for decoding or encoding.
function spicy::crc32_init() : uint64
Returns the initialization value for CRC32 computation.
function spicy::crc32_add(crc: uint64, data: bytes) : uint64
Computes a running CRC32.
function spicy::current_time() : time
Returns the current wall clock time.
function spicy::mktime(y: uint64, m: uint64, d: uint64, H: uint64, M: uint64, S: uint64) : time
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)
function spicy::bytes_to_hexstring(value: bytes) : string
Returns a bytes value rendered as a hex string.
function spicy::getenv(name: string) : optional<string>
Returns the value of an environment variable, if set.
function spicy::strftime(format: string, timestamp: time) : string
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.
function spicy::strptime(buf: string, format: string) : time
Parse time from 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.