ipfs-chromium
|
Something to which a CID may refer directly. More...
#include <library/include/ipfs_client/pb_dag.h>
Classes | |
struct | Data |
Public Types | |
enum class | Type { Raw , Directory , File , Metadata , Symlink , HAMTShard , FileChunk , NonFs , Invalid } |
The kinds of things a block may be representing. | |
Public Member Functions | |
PbDag (Cid const &cid, std::istream &stream) | |
Initialize from stream. More... | |
PbDag (Cid const &cid, ByteView bytes) | |
Initialize from block of bytes. More... | |
PbDag (Cid const &cid, std::string_view bytes) | |
PbDag (PbDag const &) | |
PbDag () | |
Construct an invalid block. | |
bool | valid () const |
Check if the block appears valid. | |
Type | type () const |
Accessor for this block's type. | |
bool | is_file () const |
type() == File || type() == FileChunk | |
std::string const & | chunk_data () const |
data field from a UnixFS node | |
std::string const & | unparsed () const |
Original bytes (with protobuf bits) | |
Cid const & | cid () const |
Getter for Content IDentifier. | |
bool | cid_matches_data (Client &) const |
Basic validation. | |
std::vector< Byte > | binary_hash (Client &, HashType=HashType::INVALID) const |
Pass INVALID to mean cid().hash_type() | |
void | List (std::function< bool(std::string const &, std::string)>) const |
std::optional< std::uint64_t > | Fanout () const |
Something to which a CID may refer directly.
A block may be "raw" - just a bunch of bytes. Or it could be an UnixFS-encoded node in a DAG Or it could be something else, like DAG-CBOR But this class really only handles the first 2 so far.
ipfs::PbDag::PbDag | ( | Cid const & | cid, |
std::istream & | stream | ||
) |
Initialize from stream.
cid | - The Content IDentifier |
stream | - Stream from which one can read the bytes of the block |
ipfs::PbDag::PbDag | ( | Cid const & | cid, |
ByteView | bytes | ||
) |
Initialize from block of bytes.
cid | - The Content IDentifier |
bytes | - The bytes to be interpreted as a maybe-node |
ipfs::PbDag::PbDag | ( | Cid const & | cid, |
std::string_view | bytes | ||
) |
Convenience constructor
cid | - The CID of the block |
bytes | - The block |