multistream.header
Functions for handling multicodec header paths.
On error, these functions throw an ExceptionInfo
with ex-data containing :type :multistream.header/invalid
to indicate the problem. The data map will also usually have :header
and :length
entries.
encode-header
(encode-header path)
Returns the byte-encoding of the header path. The path is trimmed and has a newline appended to it before encoding.
Throws a bad-header exception if the path is too long.
read!
(read! input)
Attempts to read a multicodec header from the given stream. Returns the header path.
Throws a bad-header exception if the stream does not have a valid header.
write!
(write! output path)
Writes a multicodec header for path
to the given stream. Returns the number of bytes written.