mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Extend internal API docs, part 2
Picking up from #8111. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
8ae9d66940
commit
abd5e7dec0
32 changed files with 640 additions and 359 deletions
|
@ -87,39 +87,56 @@ struct FileTransfer
|
|||
{
|
||||
virtual ~FileTransfer() { }
|
||||
|
||||
/* Enqueue a data transfer request, returning a future to the result of
|
||||
the download. The future may throw a FileTransferError
|
||||
exception. */
|
||||
/**
|
||||
* Enqueue a data transfer request, returning a future to the result of
|
||||
* the download. The future may throw a FileTransferError
|
||||
* exception.
|
||||
*/
|
||||
virtual void enqueueFileTransfer(const FileTransferRequest & request,
|
||||
Callback<FileTransferResult> callback) = 0;
|
||||
|
||||
std::future<FileTransferResult> enqueueFileTransfer(const FileTransferRequest & request);
|
||||
|
||||
/* Synchronously download a file. */
|
||||
/**
|
||||
* Synchronously download a file.
|
||||
*/
|
||||
FileTransferResult download(const FileTransferRequest & request);
|
||||
|
||||
/* Synchronously upload a file. */
|
||||
/**
|
||||
* Synchronously upload a file.
|
||||
*/
|
||||
FileTransferResult upload(const FileTransferRequest & request);
|
||||
|
||||
/* Download a file, writing its data to a sink. The sink will be
|
||||
invoked on the thread of the caller. */
|
||||
/**
|
||||
* Download a file, writing its data to a sink. The sink will be
|
||||
* invoked on the thread of the caller.
|
||||
*/
|
||||
void download(FileTransferRequest && request, Sink & sink);
|
||||
|
||||
enum Error { NotFound, Forbidden, Misc, Transient, Interrupted };
|
||||
};
|
||||
|
||||
/* Return a shared FileTransfer object. Using this object is preferred
|
||||
because it enables connection reuse and HTTP/2 multiplexing. */
|
||||
/**
|
||||
* @return a shared FileTransfer object.
|
||||
*
|
||||
* Using this object is preferred because it enables connection reuse
|
||||
* and HTTP/2 multiplexing.
|
||||
*/
|
||||
ref<FileTransfer> getFileTransfer();
|
||||
|
||||
/* Return a new FileTransfer object. */
|
||||
/**
|
||||
* @return a new FileTransfer object
|
||||
*
|
||||
* Prefer getFileTransfer() to this; see its docs for why.
|
||||
*/
|
||||
ref<FileTransfer> makeFileTransfer();
|
||||
|
||||
class FileTransferError : public Error
|
||||
{
|
||||
public:
|
||||
FileTransfer::Error error;
|
||||
std::optional<std::string> response; // intentionally optional
|
||||
/// intentionally optional
|
||||
std::optional<std::string> response;
|
||||
|
||||
template<typename... Args>
|
||||
FileTransferError(FileTransfer::Error error, std::optional<std::string> response, const Args & ... args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue