geny
package geny
- Alphabetic
- Public
- All
Type Members
- trait ByteData extends AnyRef
Encapsulates an
Array[Byte]
and provides convenience methods for reading the data out of it. - class Bytes extends AnyRef
Trivial wrapper around
Array[Byte]
with sane equality and useful toString - trait Generator[+A] extends AnyRef
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-basedhasNext
andnext: T
methods, the core is based around the push-basedgenerate
method.generate
is basically an extra-customizable version offoreach
, 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 thegenerate
call is made.Transformations on a Generator are lazy: calling methods like
filter
ormap
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 likegenerate
/foreach
/find
, or the "Conversion" methods liketoArray
or similar.generate
takes a function returningGen.Action
rather thatUnit
. 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. - trait Readable extends Writable
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. - trait Writable extends AnyRef
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 anByteArrayOutputStream
orStringBuilder
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
andInputStream
, 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.