ddn.net.tls.transport

Memory-based TLS transport for testing.

Provides an in-memory implementation of TlsTransport using byte buffers. Useful for unit testing TLS logic without real network I/O.

Types 2

In-memory transport using byte buffers.

Reads consume from inputBuffer, writes append to outputBuffer. This allows two MemoryTransport instances to be wired together for bidirectional testing.

Fields
bool open_
ubyte[] input_
ubyte[] output_
Methods
ptrdiff_t read(ubyte[] buffer)Reads bytes from the internal input buffer into `buffer`.
ptrdiff_t write(const(ubyte)[] data)Writes bytes to the internal output buffer.
void flush()No-op flush for memory transport.
void close()Closes the transport. Further reads/writes return `IoResult.CLOSED`.
bool isOpen() @property constReturns: Whether the transport is still open.
const(ubyte)[] outputBuffer() @property constReturns: The accumulated output bytes (what has been written).
const(ubyte)[] inputBuffer() @property constReturns: Remaining unread bytes in the input buffer.
void feed(const(ubyte)[] data)Appends data to the input buffer for future reads.
void clearOutput()Clears the output buffer.
PollHandle pollHandle() @property constReturns: An invalid PollHandle (memory transport has no OS handle).
Constructors
this(const(ubyte)[] initialInput = null)Constructs a MemoryTransport with optional initial input data.

Bidirectional pipe transport for integration testing.

Create a pair with PipeEnd.createPair(). Data written to one end becomes available for reading on the peer. Reads block until data is available or the transport is closed.

Fields
PipeEnd peer_
Mutex mutex_
Condition notEmpty_
ubyte[] buffer_
bool open_
bool peerClosed_
Methods
PipeEnd[2] createPair()Creates a connected pair of pipe transports.
ptrdiff_t read(ubyte[] buf)
ptrdiff_t write(const(ubyte)[] data)
void flush()
void close()
bool isOpen() @property const
PollHandle pollHandle() @property constReturns: An invalid PollHandle (pipe transport has no OS handle).
Constructors
this()Constructs a single pipe end (use `createPair()` instead).