In-memory octet streams
The only dependency is the trivial-gray-streams library.
(make-octet-input-stream seq &optional (start 0) end) => stream
Return an input stream which will supply the bytes of seq between start and end in order.
(with-octet-input-stream (var seq &optional (start 0) end) &body body)
Within body, var is bound to an octet input stream defined by seq, start and end. The result of the last form of body is returned.
(make-octet-output-stream) => stream
Return an output stream which will accumulate all the bytes written to it for the benefit of the function get-output-stream-octets.
(get-output-stream-octets stream) => bytes
Return the bytes that were written to an octet output stream.
(with-octet-output-stream (var) &body body) => bytes
Within body, var is bound to an octet output stream. After all the forms in body have been executed, the bytes that have been written to var (and that haven't been consumed by a call to get-output-stream-octets within body) are returned.
(make-octet-pipe) => stream
Return a stream which will supply the bytes that have been written to it in order.
(with-octet-pipe (var) &body body)
Within body, var is bound to an octet pipe. The result of the last form of body is returned.
(make-connected-octet-streams) => stream1, stream2
Return two streams connected to each other. The bytes written to the first stream can be read from the second, and the bytes written to the second stream can be read from the first.
(with-connected-octet-streams (var1 var2) &body body)
Within body, var1 and var2 are bound to octet streams connected to each other. The result of the last form of body is returned.
The following functions can be used on input streams, output streams and pipes.
(octet-stream-length stream) => integer
Return the number of bytes available in stream.
(octet-stream-ref stream index) => byte
Return the byte at index in stream.
(octet-stream-search stream pattern jump-table) => index or nil
Search pattern in the bytes of stream using the Boyer-Moore algorithm. The
jump-table must be 256 bytes long. If there is a match, return the index of
the beginning of the pattern in the stream, otherwise return
(make-jump-table pattern) => array
Return a jump table for pattern that can be used with octet-stream-search.
The tests require the fiveam library.