jastream 0.2.0

C#/.Net-like streams.


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

About this library

This library intends to provide streams that are similar to the streams you find in .Net, simply because I miss them when coding in D.

I'd like to note that this library makes use of exceptions for most of it's error handling.

MemoryStream

The memory stream, as the name implies, is a stream that writes directly into memory (as opposed to a file or socket).

This stream has support for std.experimental.allocator, so the programmer can decide how it allocates memory.

This stream doesn't use the GC except for exceptions, or if the given allocator uses it.

FileStream

The file stream is self explanitory.

This stream doesn't use the GC except for exceptions, or if std.stdio.File uses it.

BinaryIO

This is a helper class that can wrap around any Stream object to provide an easy way to turn primitive types and arrays of primitive types into bytes.

It should be noted that the initial code was stolen from my other library, which was designed so that all numeric types are written out in big endian. In the near future I plan on making the endianess customisable.

This also means that this stream makes liberal use of the GC.

jaster.stream.range

This module provides functions to make streams work as ranges, as well as specific range functions useful for streams.

byChunkAlloc

This function will use a given std.experimental.allocator Allocator to allocate a buffer of a specified size.

An input range is then returned which can use this buffer to provide chunks of a Stream's data at a time.

Plans

I intend to implement the following streams:

  • MemoryMappedStream

  • NetworkStream (might call it SocketStream)

At some point I will probably also write a helper class akin to BinaryIO, to work with the various strings D has for when writing text data.

I'm considering marking all of Stream's functions as @safe, forcing implementors to make sure their code is also @safe or @trusted. This has it's own set of issues though, so it'll require some thought before I come to a decision.

Examples

There's no real examples at the moment, but both the MemoryStream and BinaryIO classes have a unittest going over most of it's functionality. Though, these are more for testing rather than a documented example of how to use the classes.

Authors:
  • Sealab
Dependencies:
none
Versions:
0.2.1 2019-Jan-16
0.2.0 2019-Jan-12
0.1.0 2019-Jan-09
~master 2019-Jan-16
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 15 downloads this month

  • 36 downloads total

Score:
0.2
Short URL:
jastream.dub.pm