ddn.net.sftp.transfer
Bounded pipelined SFTP transfer engine.
SftpDownload schedules multiple positioned READ requests within explicit request-count and byte budgets, reassembles out-of-order and short responses, fills holes left by short reads, and hands ordered data to a caller sink that may accept partial writes.
SftpUpload symmetrically pipelines positioned WRITE requests, pulling bytes from a caller source and tracking every server acknowledgment. Completion means every write was acknowledged; use the capability-checked fsync extension for durability and close the handle afterwards. Accepted data (handed to the protocol) and acknowledged data (confirmed by the server) are reported separately.
Both engines never block and never reenter the caller: progress happens through SftpDownload.pump / SftpUpload.pump, driven alongside the owning client and session pumps.
The remote file is not snapshotted. A file that shrinks while a download runs surfaces as an explicit error rather than silently truncated output; an interrupted upload leaves explicitly uncertain completion, and cleanup closes the handle without replaying writes.
Types 5
Tuning bounds for one pipelined transfer.
The engine never exceeds the client's outstanding-request limit and always clamps the chunk size to the client's effective negotiated limits, regardless of the values configured here.
uint chunkSizeRequested chunk size in bytes; zero selects the client's effective chunk sizeuint maxInFlightMaximum simultaneous outstanding requestsulong byteBudgetMaximum bytes held as in-flight, reordered, or undelivered transfer stateReceives ordered download data. Returning a count smaller than the provided length applies backpressure; the remainder is retained inside the engine's byte budget and redelivered on later pumps.
Produces ordered upload data into the provided buffer. Returning zero marks the source exhausted; partial production is legal and the engine asks again on later pumps.
A bounded pipelined download from an open file handle.
The caller owns the handle; the engine only issues positioned READ requests against it. Cancelling stops scheduling and discards reordered data, but the wire request IDs stay reserved in the client until their late replies arrive.
ulong bufferedBytes() @property constReturns: bytes currently buffered as undelivered transfer state.void pump()Advances the download: moves channel bytes, processes completed reads, delivers to the sink, and schedules further requests.void cancel()Cancels the transfer. Outstanding request interest is cancelled and reordered data is discarded; the handle remains open.this(SftpClient client, const(ubyte)[] handle, ulong length,
SftpDataSink sink, SftpTransferOptions options = SftpTransferOptions.init)Constructs a download.SlotHolevoid pump()Advances the upload: moves channel bytes, records acknowledgments, and schedules further writes from the source.void cancel()Cancels the transfer. Outstanding request interest is cancelled; completion of the already-written prefix stays uncertain until the caller closes the handle.this(SftpClient client, const(ubyte)[] handle,
SftpDataSource source,
SftpTransferOptions options = SftpTransferOptions.init)Constructs an upload starting at offset zero.this(SftpClient client, const(ubyte)[] handle, ulong offset,
SftpDataSource source,
SftpTransferOptions options = SftpTransferOptions.init)Constructs an upload starting at an explicit offset.Slot