ddn.net.sftp.wire

Local wire-format reader/writer for the SFTP protocol.

The SFTP package cannot import ddn.net.ssh.wire from the SSH implementation package, so this module provides the bounded fixed-width field codec the SFTP protocol needs: length-prefixed strings, uint32/uint64, and raw bytes, all with the same before-allocation limit discipline.

Types 3

classSftpWireException : Exception

Raised for wire-format violations.

Constructors
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs a wire exception.

Sequential bounded reader over SFTP wire bytes.

Fields
private const(ubyte)[] buf_
private size_t pos_
Methods
size_t remaining() @property const pure nothrow @nogc @safeReturns: unread bytes remaining.
bool atEnd() @property const pure nothrow @nogc @safeReturns: whether the buffer is fully consumed.
ubyte readByte() @safeReads one byte.
uint readUint32() @safeReads a uint32 in network byte order.
ulong readUint64() @safeReads a uint64 in network byte order.
const(ubyte)[] readString(size_t maxLength = 32768) @safeReads a length-prefixed string as a slice (no copy).
string readText(size_t maxLength = 32768) @safeReads a string as text (copied).
void requireFullyConsumed(string context = "message") @safeAsserts the whole buffer was consumed.
private void need(size_t n, string what) @safe
Constructors
this(const(ubyte)[] data)Constructs a reader over a buffer.

Growable bounded writer for SFTP wire bytes.

Fields
private ubyte[] buf_
Methods
void putByte(ubyte b) @safe pure nothrowWrites one byte.
void putUint32(uint v) @safe pure nothrowWrites a uint32 in network byte order.
void putUint64(ulong v) @safe pure nothrowWrites a uint64 in network byte order.
void putString(scope const(ubyte)[] data, size_t maxLength = 35000) @safe pureWrites a length-prefixed string.
void putRaw(scope const(ubyte)[] data) @safe pure nothrowWrites raw bytes without a length prefix.
ubyte[] data() @safe pure nothrowReturns: the accumulated bytes (the internal buffer, not a copy).
const(ubyte)[] peek() @property const @safe pure nothrowReturns: a const view of the accumulated bytes.
void clear() @safe pure nothrowResets the writer.

Functions 1

private fnstring bytesToText(const(ubyte)[] data) @trusted pure