|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
#include <ndn/link.hpp>
Public Member Functions | |
| Link ()=default | |
| Default constructor. | |
| Link (const Name &name) | |
| Create a Link with a specified Name. | |
Delegation management | |
| Error | addDelegation (const Name &delegation) |
| Add a delegation (Name) | |
| Error | addDelegation (std::string_view uri) |
| Add a delegation from a URI string. | |
| size_t | delegationCount () const |
| Get the number of delegations. | |
| const Name * | delegation (size_t index) const |
| Get a delegation by index. | |
| void | clearDelegations () |
| Clear all delegations. | |
| bool | hasDelegation (const Name &name) const |
| Check if a given Name is in the delegation list. | |
Name access | |
| const Name & | name () const |
| Get the Name (const reference) | |
| Name & | name () |
| Get the Name (reference) | |
| Link & | setName (const Name &name) |
| Set the Name. | |
| Error | setName (std::string_view uri) |
| Set the Name from a URI string. | |
Conversion to Data | |
| Error | toData (Data &data) const |
| Convert the Link to a Data packet. | |
| static Result< Link > | fromData (const Data &data) |
| Decode a Link from a Data packet. | |
NDN Link Object.
A Link Object is a special Data packet with ContentType=LINK, containing one or more Names (delegations) in its Content field. Provides a list of Names sorted by producer priority.
|
default |
Default constructor.
Creates an empty Link.
|
explicit |
Add a delegation (Name)
Add in order of producer priority. The first added has the highest priority.
| delegation | Name to add |
Definition at line 23 of file link.cpp.
References delegation(), and ndn::LINK_MAX_DELEGATIONS.
Referenced by addDelegation(), and fromData().
| Error ndn::Link::addDelegation | ( | std::string_view | uri | ) |
Add a delegation from a URI string.
| uri | URI string (e.g., "/ndn/jp/provider") |
Definition at line 39 of file link.cpp.
References addDelegation(), and ndn::Name::fromUri().
| const Name * ndn::Link::delegation | ( | size_t | index | ) | const |
Get a delegation by index.
| index | Delegation index (starting from 0) |
Definition at line 47 of file link.cpp.
Referenced by addDelegation().
|
inline |
Decode a Link from a Data packet.
Extracts the delegation list from a Data with ContentType=LINK.
| data | Input Data |
Definition at line 97 of file link.cpp.
References addDelegation(), ndn::Data::content(), ndn::Data::contentSize(), ndn::Data::contentType(), ndn::TlvDecoder::current(), ndn::Name::fromWire(), ndn::Data::hasContent(), ndn::TlvDecoder::hasMore(), ndn::Data::name(), ndn::TlvDecoder::remaining(), ndn::TlvDecoder::skip(), and ndn::Result< T >::value.
| bool ndn::Link::hasDelegation | ( | const Name & | name | ) | const |
|
inline |
|
inline |
| Error ndn::Link::setName | ( | std::string_view | uri | ) |
Set the Name from a URI string.
| uri | URI string |
Definition at line 14 of file link.cpp.
References ndn::Name::fromUri().
Convert the Link to a Data packet.
Generates a Data packet with ContentType=LINK. The Content contains the encoded delegations (list of Names). Signing is not performed by this method.
| data | Output Data |
Definition at line 67 of file link.cpp.
References ndn::TlvEncoder::current(), ndn::DATA_MAX_CONTENT_SIZE, ndn::TlvEncoder::position(), ndn::TlvEncoder::remaining(), ndn::Data::setContent(), ndn::Data::setContentType(), ndn::Data::setName(), ndn::TlvEncoder::setPosition(), and ndn::TlvEncoder::size().