ipfs-chromium
Classes | Public Types | Public Member Functions | List of all members
ipfs::PbDag Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PbDag() [1/2]

ipfs::PbDag::PbDag ( Cid const &  cid,
std::istream &  stream 
)

Initialize from stream.

Parameters
cid- The Content IDentifier
stream- Stream from which one can read the bytes of the block

◆ PbDag() [2/2]

ipfs::PbDag::PbDag ( Cid const &  cid,
ByteView  bytes 
)

Initialize from block of bytes.

Parameters
cid- The Content IDentifier
bytes- The bytes to be interpreted as a maybe-node
Note
It's not really a string - certainly not text in any way. It's just a container of arbitrary bytes.

The documentation for this class was generated from the following files: