geny
Type members
Classlikes
Encapsulates an Array[Byte] and provides convenience methods for
reading the data out of it.
Encapsulates an Array[Byte] and provides convenience methods for
reading the data out of it.
- Companion:
- object
Trivial wrapper around Array[Byte] with sane equality and useful toString
Trivial wrapper around Array[Byte] with sane equality and useful toString
Provides the geny.Gen data type, A Generator of elements of type A.
Provides the geny.Gen data type, A Generator of elements of type A.
Generator is basically the inverse of
a scala.Iterator: instead of the core functionality being the pull-based
hasNext and next: T methods, the core is based around the push-based
generate method. generate is basically an extra-customizable version of
foreach, which allows the person calling it to provide basic control-flow
instructions to the upstream Gens.
Unlike a scala.Iterator, subclasses of Generator can guarantee any clean
up logic is performed by placing it after the generate call is made.
Transformations on a Generator are lazy: calling methods like filter
or map do not evaluate the entire Gen, but instead construct a new
Gen that delegates to the original. The only methods that evaluate
the Generator are the "Action" methods like
generate/foreach/find, or the "Conversion" methods like toArray or
similar.
generate takes a function returning Gen.Action rather that
Unit. This allows a downstream Gen to provide basic control
commands to the upstream Gens: i.e. Generator.End to cease
enumeration of the upstream Gen. This allows it to avoid traversing and
processing elements that the downstream Gen doesn't want/need to see
anyway.
- Companion:
- object
A Readable is a source of bytes that can be read from an InputStream
A Readable is a source of bytes that can be read from an InputStream
A subtype of Writable, every Readable can be trivially used as a Writable by transferring the bytes from the InputStream to the OutputStream, but not every Writable is a Readable.
Note that the InputStream is only available inside the readBytesThrough, and
may be closed and cleaned up (along with any associated resources) once the
callback returns.
- Companion:
- object
A Writable is a source of bytes that can be written to an OutputStream.
A Writable is a source of bytes that can be written to an OutputStream.
Essentially a push-based version of java.io.InputStream, that allows an
implementation to guarantee that cleanup logic runs after the bytes are
written.
Writable is also much easier to implement than java.io.InputStream: any
code that previously wrote output to an ByteArrayOutputStream or
StringBuilder can trivially satisfy the Writable interface. That makes
Writable very convenient to use for allowing zero-friction zero-overhead
streaming data exchange between different libraries.
Writable comes with implicit constructors from Array[Byte], String
and InputStream, and is itself a tiny interface with minimal functionality.
Libraries using Writable are expected to extend it to provide additional
methods or additional implicit constructors that make sense in their context.
- Companion:
- object