Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
filetransfer.hh
Go to the documentation of this file.
1#pragma once
3
5#include "lix/libutil/ref.hh"
10
11#include <string>
12#include <future>
13
14namespace nix {
15
16struct FileTransferSettings : Config
17{
18 #include "file-transfer-settings.gen.inc"
19};
20
21extern FileTransferSettings fileTransferSettings;
22
24{
25 bool cached = false;
26 std::string etag;
27 std::string effectiveUri;
28 /* An "immutable" URL for this resource (i.e. one whose contents
29 will never change), as returned by the `Link: <url>;
30 rel="immutable"` header. */
31 std::optional<std::string> immutableUrl;
32};
33
34class Store;
35
37{
38 virtual ~FileTransfer() { }
39
43 virtual void
44 upload(const std::string & uri, std::string data, const Headers & headers = {}) = 0;
45
56 virtual bool exists(const std::string & uri, const Headers & headers = {}) = 0;
57
65 virtual std::pair<FileTransferResult, box_ptr<Source>>
66 download(const std::string & uri, const Headers & headers = {}) = 0;
67
68 enum Error { NotFound, Forbidden, Misc, Transient, Interrupted };
69};
70
77ref<FileTransfer> getFileTransfer();
78
84ref<FileTransfer> makeFileTransfer(std::optional<unsigned int> baseRetryTimeMs = {});
85
86class FileTransferError : public Error
87{
88public:
89 FileTransfer::Error error;
91 std::optional<std::string> response;
92
93 template<typename... Args>
94 FileTransferError(FileTransfer::Error error, std::optional<std::string> response, const Args & ... args);
95};
96
97}
Definition args.hh:31
std::optional< std::string > response
intentionally optional
Definition filetransfer.hh:91
Definition store-api.hh:195
Definition ref.hh:19
Definition filetransfer.hh:24
Definition filetransfer.hh:17
Definition filetransfer.hh:37
virtual void upload(const std::string &uri, std::string data, const Headers &headers={})=0
virtual std::pair< FileTransferResult, box_ptr< Source > > download(const std::string &uri, const Headers &headers={})=0
virtual bool exists(const std::string &uri, const Headers &headers={})=0