TMemoryBuffer

A transport that simply reads from and writes to an in-memory buffer. Every time you call write on it, the data is simply placed into a buffer, and every time you call read, data is consumed from that buffer.

Currently, the storage for written data is never reclaimed, even if the buffer contents have already been read out again.

Constructors

this
this()

Constructs a new memory transport with an empty internal buffer.

this
this(size_t capacity)

Constructs a new memory transport with an empty internal buffer, reserving space for capacity bytes in advance.

this
this(ubyte[] contents)

Constructs a new memory transport initially containing the passed data.

Destructor

~this
~this()

Destructor, frees the internally allocated buffer.

Members

Functions

borrow
const(ubyte)[] borrow(ubyte* buf, size_t len)
Undocumented in source. Be warned that the author may not have intended to support it.
close
void close()

Closing is a no-op() for a memory buffer, it is always open.

consume
void consume(size_t len)
Undocumented in source. Be warned that the author may not have intended to support it.
getContents
const(ubyte)[] getContents()

Returns a read-only view of the current buffer contents.

isOpen
bool isOpen()

A memory transport is always open.

open
void open()

Opening is a no-op() for a memory buffer.

peek
bool peek()
Undocumented in source. Be warned that the author may not have intended to support it.
read
size_t read(ubyte[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.
readAll
void readAll(ubyte[] buf)

Shortcut version of readAll() – using this over TBaseTransport.readAll() can give us a nice speed increase because gives us a nice speed increase because it is typically a very hot path during deserialization.

reset
void reset()
Undocumented in source. Be warned that the author may not have intended to support it.
reset
void reset(size_t capacity)
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ubyte[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From TBaseTransport

isOpen
bool isOpen()
Undocumented in source. Be warned that the author may not have intended to support it.
peek
bool peek()
Undocumented in source. Be warned that the author may not have intended to support it.
open
void open()
Undocumented in source. Be warned that the author may not have intended to support it.
close
void close()
Undocumented in source. Be warned that the author may not have intended to support it.
read
size_t read(ubyte[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.
readAll
void readAll(ubyte[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.
readEnd
size_t readEnd()
Undocumented in source. Be warned that the author may not have intended to support it.
write
void write(ubyte[] buf)
Undocumented in source. Be warned that the author may not have intended to support it.
writeEnd
size_t writeEnd()
Undocumented in source. Be warned that the author may not have intended to support it.
flush
void flush()
Undocumented in source. Be warned that the author may not have intended to support it.
borrow
const(ubyte)[] borrow(ubyte* buf, size_t len)
Undocumented in source. Be warned that the author may not have intended to support it.
consume
void consume(size_t len)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta