diff --git a/library/include/ipfs_client/crypto/hasher.h b/library/include/ipfs_client/crypto/hasher.h index d7fcf289..02aa6dd4 100644 --- a/library/include/ipfs_client/crypto/hasher.h +++ b/library/include/ipfs_client/crypto/hasher.h @@ -13,7 +13,10 @@ class Hasher { public: virtual ~Hasher() noexcept {} - virtual std::optional> hash(ByteView) = 0; + /*! @param bytes Bytes to hash + * @return The digest or nullopt if there was an error + */ + virtual std::optional> hash(ByteView bytes) = 0; }; } // namespace ipfs::crypto diff --git a/library/include/ipfs_client/crypto/signature_verifier.h b/library/include/ipfs_client/crypto/signature_verifier.h index bd6865e5..70b73cca 100644 --- a/library/include/ipfs_client/crypto/signature_verifier.h +++ b/library/include/ipfs_client/crypto/signature_verifier.h @@ -11,6 +11,8 @@ namespace ipfs::crypto { class SignatureVerifier { public: virtual ~SignatureVerifier() noexcept {} + /*! Non-owned bytes + */ using ByteView = ipfs::ByteView; virtual bool VerifySignature(ByteView signature, ByteView data, diff --git a/library/include/ipfs_client/ctx/cbor_parser.h b/library/include/ipfs_client/ctx/cbor_parser.h index 7d8ca80b..0c51abe2 100644 --- a/library/include/ipfs_client/ctx/cbor_parser.h +++ b/library/include/ipfs_client/ctx/cbor_parser.h @@ -14,7 +14,10 @@ namespace ipfs::ctx { */ class CborParser { public: - virtual std::unique_ptr Parse(ByteView) = 0; + /*! @param cbor The CBOR to parse + * @return The DOM value, or NULL if there was an error + */ + virtual std::unique_ptr Parse(ByteView cbor) = 0; virtual ~CborParser() noexcept {} }; } // namespace ipfs::ctx diff --git a/library/include/ipfs_client/ctx/dns_txt_lookup.h b/library/include/ipfs_client/ctx/dns_txt_lookup.h index 7da94ca6..fd696760 100644 --- a/library/include/ipfs_client/ctx/dns_txt_lookup.h +++ b/library/include/ipfs_client/ctx/dns_txt_lookup.h @@ -10,6 +10,8 @@ namespace ipfs::ctx { */ class DnsTxtLookup { public: + /*! Callback for if usable result was achieved + */ using DnsTextResultsCallback = std::function const&)>; using DnsTextCompleteCallback = std::function; diff --git a/library/include/ipfs_client/ctx/gateway_config.h b/library/include/ipfs_client/ctx/gateway_config.h index 66838c24..d4c09b88 100644 --- a/library/include/ipfs_client/ctx/gateway_config.h +++ b/library/include/ipfs_client/ctx/gateway_config.h @@ -13,6 +13,10 @@ namespace ipfs::ctx { class GatewayConfig { public: virtual ~GatewayConfig() noexcept {} + /*! Position-based access (indexing) + * @param index The 0-based index of the gateway in question + * @return The spec for the gateway iff index < count of gateways, nullopt otherwise + */ virtual std::optional GetGateway(std::size_t index) const = 0; virtual unsigned GetGatewayRate(std::string_view url_prefix) = 0; virtual int GetTypeAffinity(std::string_view url_prefix, diff --git a/library/include/ipfs_client/ctx/http_api.h b/library/include/ipfs_client/ctx/http_api.h index f64b18bf..7037889c 100644 --- a/library/include/ipfs_client/ctx/http_api.h +++ b/library/include/ipfs_client/ctx/http_api.h @@ -10,6 +10,8 @@ namespace ipfs::ctx { */ class HttpApi { public: + /*! Description of the request to be sent + */ using ReqDesc = ::ipfs::HttpRequestDescription; using Hdrs = std::function; using OnComplete = std::function; diff --git a/library/include/ipfs_client/ctx/json_parser.h b/library/include/ipfs_client/ctx/json_parser.h index ec3a0e3c..6dfa77a4 100644 --- a/library/include/ipfs_client/ctx/json_parser.h +++ b/library/include/ipfs_client/ctx/json_parser.h @@ -14,7 +14,10 @@ namespace ipfs::ctx { class JsonParser { public: virtual ~JsonParser() noexcept {} - virtual std::unique_ptr Parse(std::string_view) = 0; + /*! @param json The JSON text to parse + * @return The DOM object or NULL if parsing failed. + */ + virtual std::unique_ptr Parse(std::string_view json) = 0; }; } // namespace ipfs::ctx diff --git a/library/include/ipfs_client/ctx/null_cbor_parser.h b/library/include/ipfs_client/ctx/null_cbor_parser.h index 047ab5f8..c74dff4c 100644 --- a/library/include/ipfs_client/ctx/null_cbor_parser.h +++ b/library/include/ipfs_client/ctx/null_cbor_parser.h @@ -7,6 +7,8 @@ namespace ipfs::ctx { */ class NullCborParser : public CborParser { public: + /*! @return NULL, always + */ std::unique_ptr Parse(ByteView) override { return {}; } diff --git a/library/include/ipfs_client/gw/dnslink_requestor.h b/library/include/ipfs_client/gw/dnslink_requestor.h index 8f0f0c44..6b3da28b 100644 --- a/library/include/ipfs_client/gw/dnslink_requestor.h +++ b/library/include/ipfs_client/gw/dnslink_requestor.h @@ -12,7 +12,9 @@ namespace ipfs::gw { */ class DnsLinkRequestor final : public Requestor { public: - explicit DnsLinkRequestor(std::shared_ptr); + /*! @param api The Client context API + */ + explicit DnsLinkRequestor(std::shared_ptr api); HandleOutcome handle(RequestPtr) override; std::string_view name() const override; diff --git a/library/include/ipfs_client/gw/gateway_request.h b/library/include/ipfs_client/gw/gateway_request.h index 8a4cce86..51f56813 100644 --- a/library/include/ipfs_client/gw/gateway_request.h +++ b/library/include/ipfs_client/gw/gateway_request.h @@ -38,6 +38,8 @@ constexpr std::size_t CAR_RESPONSE_BUFFER_SIZE = 5UL * 1024UL * 1024UL; */ class GatewayRequest : public std::enable_shared_from_this { public: + /*! Type for callbacks for when bytes are received + */ using BytesReceivedHook = std::function; @@ -79,6 +81,9 @@ class GatewayRequest : public std::enable_shared_from_this { std::string debug_string() const; void orchestrator(std::shared_ptr const&); bool cachable() const; + + /*! @return The part of the path that functions as an origin (the second component) + */ std::string_view root_component() const; void root_component(std::string_view); diff --git a/library/include/ipfs_client/gw/inline_request_handler.h b/library/include/ipfs_client/gw/inline_request_handler.h index ed298730..32e6e226 100644 --- a/library/include/ipfs_client/gw/inline_request_handler.h +++ b/library/include/ipfs_client/gw/inline_request_handler.h @@ -10,7 +10,11 @@ namespace ipfs::gw { */ class InlineRequestHandler final : public Requestor { public: - HandleOutcome handle(RequestPtr) override; + /*! @param request The request to try handling + * @return DONE (after responding) if it was an inline request + * NOT_HANDLED otherwise + */ + HandleOutcome handle(RequestPtr request) override; std::string_view name() const override; }; } // namespace ipfs::gw diff --git a/library/include/ipfs_client/gw/requestor.h b/library/include/ipfs_client/gw/requestor.h index 7eac8db6..cf2b03f9 100644 --- a/library/include/ipfs_client/gw/requestor.h +++ b/library/include/ipfs_client/gw/requestor.h @@ -41,6 +41,9 @@ class Requestor : public std::enable_shared_from_this { public: using RequestPtr = ::ipfs::gw::RequestPtr; + /*! @return The requestor's name, for debugging. + * Typically this is 1:1 with the concrete type. + */ virtual std::string_view name() const = 0; virtual ~Requestor() noexcept {} diff --git a/library/include/ipfs_client/gw/terminating_requestor.h b/library/include/ipfs_client/gw/terminating_requestor.h index 0e6816b4..3626c742 100644 --- a/library/include/ipfs_client/gw/terminating_requestor.h +++ b/library/include/ipfs_client/gw/terminating_requestor.h @@ -9,9 +9,8 @@ namespace ipfs::gw { */ class TerminatingRequestor : public Requestor { public: - using HandleOutcome = Requestor::HandleOutcome; std::string_view name() const override; - HandleOutcome handle(RequestPtr) override; + Requestor::HandleOutcome handle(RequestPtr) override; }; } // namespace ipfs::gw diff --git a/library/include/ipfs_client/ipld/block_source.h b/library/include/ipfs_client/ipld/block_source.h index f7944593..7bfef41c 100644 --- a/library/include/ipfs_client/ipld/block_source.h +++ b/library/include/ipfs_client/ipld/block_source.h @@ -10,6 +10,8 @@ namespace ipfs::ipld { /*! Description of where a particular block was fetched from, for diagnostics */ struct BlockSource { + /*! Source of now(). Defines timestamp type. + */ using Clock = std::chrono::system_clock; /*! Categorization of sources diff --git a/library/include/ipfs_client/ipld/dag_headers.h b/library/include/ipfs_client/ipld/dag_headers.h index 1a43e242..3fb656d8 100644 --- a/library/include/ipfs_client/ipld/dag_headers.h +++ b/library/include/ipfs_client/ipld/dag_headers.h @@ -14,6 +14,9 @@ class DagHeaders { public: void Add(BlockSource const&); void Finish(); + + /*! A list of HTTP header names and values + */ using HeaderList = std::vector>; HeaderList const& headers() const { return headers_; } diff --git a/library/include/ipfs_client/ipld/dag_node.h b/library/include/ipfs_client/ipld/dag_node.h index 8b48d1c3..dbffa493 100644 --- a/library/include/ipfs_client/ipld/dag_node.h +++ b/library/include/ipfs_client/ipld/dag_node.h @@ -73,6 +73,9 @@ class DagNode : public std::enable_shared_from_this { virtual ResolveResult resolve(ResolutionState& params) = 0; protected: + /*! The child nodes of this node, possibly not yet fetched. + * @note In some cases the string is empty. For example as stem node of a UnixFS (multi-node) file. + */ std::vector> links_; std::shared_ptr api_; @@ -147,7 +150,10 @@ class DagNode : public std::enable_shared_from_this { */ virtual bool PreferOver(DagNode const& another) const; - void set_api(std::shared_ptr); + /*! Provide the Client API to be used in DAG operations + * @param api Shared pointer to API for the context being run in + */ + void set_api(std::shared_ptr api); void source(BlockSource src) { source_ = src; } }; } // namespace ipfs::ipld diff --git a/library/include/ipfs_client/ipld/link.h b/library/include/ipfs_client/ipld/link.h index 43cb7c32..90a4feb2 100644 --- a/library/include/ipfs_client/ipld/link.h +++ b/library/include/ipfs_client/ipld/link.h @@ -19,7 +19,7 @@ class Link { Ptr node; /*! Construct an unresolved IPLD link - * @param The child's CID + * @param cid The child's CID */ explicit Link(std::string cid); /*! Construct a resolved IPLD link diff --git a/library/include/ipfs_client/ipld/resolution_state.h b/library/include/ipfs_client/ipld/resolution_state.h index 80e3e7eb..b0e51dad 100644 --- a/library/include/ipfs_client/ipld/resolution_state.h +++ b/library/include/ipfs_client/ipld/resolution_state.h @@ -25,7 +25,14 @@ class ResolutionState { BlockLookup get_available_block; public: - ResolutionState(SlashDelimited path_to_resolve, ResponseSemantic, BlockLookup); + /*! Construct from starting info + * @param path_to_resolve Relative to the node resolve is being called on + * @param semantic If the resolution results in a stem, i.e. a directory-like not a file, + * would the preference be for a listing preview HTML page -OR- + * JSON that describes the links to files and CIDs to merge in with this JSON (in the case of a sharded dir) + * @param lookup Functor that returns a pointer to a node for a given CID if it's already availabe, nullptr otherwise. + */ + ResolutionState(SlashDelimited path_to_resolve, ResponseSemantic semantic, BlockLookup lookup); SlashDelimited MyPath() const; SlashDelimited PathToResolve() const; diff --git a/library/include/ipfs_client/ipns_record.h b/library/include/ipfs_client/ipns_record.h index c85efc2d..c8a4a24e 100644 --- a/library/include/ipfs_client/ipns_record.h +++ b/library/include/ipfs_client/ipns_record.h @@ -54,7 +54,9 @@ struct ValidatedIpns { std::string gateway_source; ///< Who gave us this record? ValidatedIpns(); ///< Create an invalid default object - explicit ValidatedIpns(IpnsCborEntry const&); + /*! @param entry IPNS entry known to be valid + */ + explicit ValidatedIpns(IpnsCborEntry const& entry); ValidatedIpns(ValidatedIpns&&); ValidatedIpns(ValidatedIpns const&); ValidatedIpns& operator=(ValidatedIpns const&); diff --git a/library/include/ipfs_client/multi_base.h b/library/include/ipfs_client/multi_base.h index 71308112..e741aaec 100644 --- a/library/include/ipfs_client/multi_base.h +++ b/library/include/ipfs_client/multi_base.h @@ -42,7 +42,7 @@ struct Codec { * Should match the name found in the multibase table. */ std::string_view const name; - /*! @param Struct with the above fields filled + /*! @return Struct with the above fields filled * @param code The multibase to fetch */ static Codec const* Get(Code code); diff --git a/library/include/ipfs_client/partition.h b/library/include/ipfs_client/partition.h index 8c8b284d..6d0903b8 100644 --- a/library/include/ipfs_client/partition.h +++ b/library/include/ipfs_client/partition.h @@ -17,8 +17,6 @@ class Client; */ class Partition : public std::enable_shared_from_this { public: - using GatewayAccess = - std::function)>; using MimeDetection = std::function< std::string(std::string, std::string_view, std::string const&)>; void build_response(std::shared_ptr); diff --git a/library/include/ipfs_client/pb_dag.h b/library/include/ipfs_client/pb_dag.h index 60bf2cb5..7afc2d08 100644 --- a/library/include/ipfs_client/pb_dag.h +++ b/library/include/ipfs_client/pb_dag.h @@ -38,6 +38,10 @@ class PbDag { * It's just a container of arbitrary bytes. */ PbDag(Cid const& cid, ByteView bytes); + /*! Convenience constructor + * @param cid - The CID of the block + * @param bytes - The block + */ PbDag(Cid const& cid, std::string_view bytes); PbDag(PbDag const&); diff --git a/library/include/ipfs_client/response.h b/library/include/ipfs_client/response.h index ed8e918d..ccbfe702 100644 --- a/library/include/ipfs_client/response.h +++ b/library/include/ipfs_client/response.h @@ -24,6 +24,9 @@ struct Response { static Response PLAIN_NOT_FOUND; static Response IMMUTABLY_GONE; static Response HOST_NOT_FOUND_RESPONSE; + /*! @param body HTML text (the response of the body, not the `` + * @param location The Location header + */ static Response html(std::string_view body, std::string_view location = {}); }; diff --git a/library/include/vocab/raw_ptr.h b/library/include/vocab/raw_ptr.h index 25405d3e..4d7a3327 100644 --- a/library/include/vocab/raw_ptr.h +++ b/library/include/vocab/raw_ptr.h @@ -37,6 +37,8 @@ class raw_ptr { // construct. Set it to nullptr. We have time needed to read_start a word. raw_ptr() = delete; + /*! @param p Primitive raw pointer + */ raw_ptr(T* p) : ptr_{p} {} raw_ptr(raw_ptr&&) = default; raw_ptr(raw_ptr const&) = default; diff --git a/library/include/vocab/slash_delimited.h b/library/include/vocab/slash_delimited.h index 948a8a6a..988c57d8 100644 --- a/library/include/vocab/slash_delimited.h +++ b/library/include/vocab/slash_delimited.h @@ -17,6 +17,8 @@ struct SlashDelimited { public: SlashDelimited() : remainder_{""} {} + /*! @param unowned Text to parse into /-delimited components + */ explicit SlashDelimited(std::string_view unowned); explicit operator bool() const; std::string_view pop(); diff --git a/library/src/ipfs_client/gw/gateway_state.h b/library/src/ipfs_client/gw/gateway_state.h index dd64c112..4030d7a2 100644 --- a/library/src/ipfs_client/gw/gateway_state.h +++ b/library/src/ipfs_client/gw/gateway_state.h @@ -38,7 +38,11 @@ class GatewayState { ctx::GatewayConfig const& cfg() const; public: - GatewayState(std::string_view prefix, std::shared_ptr); + /*! @param prefix The URL prefix that goes in front of HTTP requests to the gateway + * e.g. https://ipfs.io/ + * @param api Access to the functionality of this client's context + */ + GatewayState(std::string_view prefix, std::shared_ptr api); long score(GatewayRequest const&, unsigned) const; bool bored() const; bool over_rate(); diff --git a/library/src/ipfs_client/gw/multi_gateway_requestor.h b/library/src/ipfs_client/gw/multi_gateway_requestor.h index f3b9397b..6d6eb274 100644 --- a/library/src/ipfs_client/gw/multi_gateway_requestor.h +++ b/library/src/ipfs_client/gw/multi_gateway_requestor.h @@ -31,6 +31,8 @@ class MultiGatewayRequestor : public Requestor { void Next(); public: + /*! @return "multi-gateway requestor" + */ std::string_view name() const override; HandleOutcome handle(RequestPtr) override; }; diff --git a/library/src/ipfs_client/ipld/chunk.h b/library/src/ipfs_client/ipld/chunk.h index cb5a12c1..af173be6 100644 --- a/library/src/ipfs_client/ipld/chunk.h +++ b/library/src/ipfs_client/ipld/chunk.h @@ -16,7 +16,10 @@ class Chunk : public DagNode { ResolveResult resolve(ResolutionState&) override; public: - explicit Chunk(std::string); + /*! Construct + * @param bytes The blob itself + */ + explicit Chunk(std::string bytes); ~Chunk() noexcept override; }; } // namespace ipfs::ipld diff --git a/library/src/ipfs_client/ipld/dag_cbor_node.h b/library/src/ipfs_client/ipld/dag_cbor_node.h index d2547682..3a8630f2 100644 --- a/library/src/ipfs_client/ipld/dag_cbor_node.h +++ b/library/src/ipfs_client/ipld/dag_cbor_node.h @@ -12,6 +12,8 @@ class DagCborNode final : public DagNode { ResolveResult resolve(ResolutionState&) override; public: + /*! The dict or document being represented + */ using Data = DagCborValue; explicit DagCborNode(std::unique_ptr); ~DagCborNode() noexcept override; diff --git a/library/src/ipfs_client/ipld/directory_shard.h b/library/src/ipfs_client/ipld/directory_shard.h index d7c897c7..37b0e859 100644 --- a/library/src/ipfs_client/ipld/directory_shard.h +++ b/library/src/ipfs_client/ipld/directory_shard.h @@ -4,6 +4,8 @@ #include namespace ipfs::ipld { +/*! A node in a sharded (HAMT) directory + */ class DirShard : public DagNode { std::uint64_t const fanout_; @@ -21,6 +23,7 @@ class DirShard : public DagNode { public: /*! Construct with a known fanout + * @param fanout The number of buckets */ explicit DirShard(std::uint64_t fanout = 256UL); ~DirShard() noexcept override; diff --git a/library/src/ipfs_client/ipld/root.h b/library/src/ipfs_client/ipld/root.h index 7d8e2930..3cb604be 100644 --- a/library/src/ipfs_client/ipld/root.h +++ b/library/src/ipfs_client/ipld/root.h @@ -7,6 +7,9 @@ #include namespace ipfs::ipld { +/*! Since some operations will behave differently if a given node is being treated as + * a DAG root, this proxy wraps around a node to give it those properties + */ class Root : public DagNode { std::optional redirects_; @@ -16,7 +19,10 @@ class Root : public DagNode { bool expired() const override; public: - explicit Root(std::shared_ptr); + /*! Construct + * @param node The actual node being treated as a DAG root + */ + explicit Root(std::shared_ptr node); ~Root() noexcept override; }; } // namespace ipfs::ipld diff --git a/library/src/ipfs_client/ipld/symlink.h b/library/src/ipfs_client/ipld/symlink.h index 8d21a3aa..296e07b2 100644 --- a/library/src/ipfs_client/ipld/symlink.h +++ b/library/src/ipfs_client/ipld/symlink.h @@ -12,6 +12,12 @@ class Symlink : public DagNode { bool is_absolute() const; public: + /*! Construct from the text of the target + * @target Either a path relative to this node's, + * OR /an/absolute/path which is relative to the DAG root + * @note If it points outside the DAG it'll be considered broken. + * This can be achieved by simply using too many ../../.. + */ explicit Symlink(std::string target); ~Symlink() noexcept override; }; diff --git a/library/src/ipfs_client/redirects.h b/library/src/ipfs_client/redirects.h index ebb70e65..266cbf43 100644 --- a/library/src/ipfs_client/redirects.h +++ b/library/src/ipfs_client/redirects.h @@ -17,7 +17,11 @@ class Directive { int const status_; public: - Directive(std::string_view, std::string_view, int); + /*! @param from path/glob to match against + * @param to partial path to replace from with + * @param status HTTP status to use in successful response that hit this rule + */ + Directive(std::string_view from, std::string_view to, int status); std::uint16_t rewrite(std::string&) const; std::string error() const; bool valid() const { return error().empty(); }