cl-octet-streams

2018-03-28

cl-octet-streams is a library implementing in-memory octet streams for Common Lisp. It was inspired by the trivial-octet-streams and cl-plumbing libraries.

Installation

The only dependency is the trivial-gray-streams library.

API

Input stream

(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.

Output stream

(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.

Pipe

(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.

Connected streams

(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.

Tests

The tests require the fiveam library.

(asdf:test-system "cl-octet-streams")
Author
Guillaume LE VAILLANT
License
GPL-3