ipfs-chromium
ipfs_request.h
1 #ifndef IPFS_IPFS_REQUEST_H_
2 #define IPFS_IPFS_REQUEST_H_
3 
4 #include <ipfs_client/response_semantic.h>
5 #include <vocab/slash_delimited.h>
6 
7 #include <functional>
8 #include <memory>
9 #include <string>
10 
11 namespace ipfs {
12 struct Response;
15 class IpfsRequest {
16  public:
17  using Cleanup = std::function<void()>;
18  using Finisher = std::function<void(IpfsRequest const&, Response const&)>;
19 
20  private:
21  std::string path_;
22  Finisher callback_;
23  ResponseSemantic semantic_;
24  std::vector<Cleanup> cleanups_;
25 
26  public:
27  IpfsRequest(std::string path, Finisher);
28  ~IpfsRequest() noexcept;
29 
30  SlashDelimited path() const { return SlashDelimited{path_}; }
31  ResponseSemantic semantic() const { return semantic_; }
32  bool done() const;
33 
34  IpfsRequest& semantic(std::string_view);
35  void finish(Response& r);
36  void new_path(std::string_view);
37  void to_cleanup(Cleanup);
38 
39  static std::shared_ptr<IpfsRequest> fromUrl(std::string url, Finisher);
40 };
41 } // namespace ipfs
42 
43 #endif // IPFS_IPFS_REQUEST_H_
Definition: ipfs_request.h:15
Definition: response.h:17
Definition: slash_delimited.h:15