Link class

A directed link between nodes in the IPFS Merkle DAG.

Links are the edges in IPFS's content-addressed graph structure, connecting parent nodes to their children. Each link contains:

  • A name identifying the link within its parent
  • A cid pointing to the target node's content
  • A size representing the cumulative size of the linked subgraph

This class strictly follows the IPFS PBLink protobuf specification. Note that metadata like timestamps or directory flags must be resolved by fetching the target node.

Example:

final link = Link(
  name: 'readme.md',
  cid: fileCid,
  size: 1024,
);

// Links in a directory listing
for (final link in node.links) {
  // print('${link.name}: ${link.cid}');
}

See also:

  • MerkleDAGNode for the node structure containing links
  • CID for content identifiers

Constructors

Link({required String name, required CID cid, required int size})
Creates a new link with the given name, cid, and size.
Link.fromProto(PBLink proto)
Creates a Link from a standard PBLink proto.
factory

Properties

cid → CID
The content identifier of the linked target node.
final
hashCode → int
The hash code for this object.
no setterinherited
name → String
The name of this link within its parent node.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → Int64
The cumulative size of the linked subgraph in bytes.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toProto() → PBLink
Converts the link to its protobuf representation.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited