Class for RDR-style metadata encoding/decoding. More...
#include <metadata-object.hpp>
Classes | |
class | Error |
Public Member Functions | |
MetadataObject () | |
Create an empty metadata object. More... | |
MetadataObject (const Data &data) | |
Construct a metadata object by decoding of the given Data packet. More... | |
NDN_CXX_NODISCARD Data | makeData (Name discoveryInterestName, KeyChain &keyChain, const ndn::security::SigningInfo &si=KeyChain::getDefaultSigningInfo(), optional< uint64_t > version=nullopt, time::milliseconds freshnessPeriod=10_ms) const |
Create a Data packet representing this metadata object. More... | |
const Name & | getVersionedName () const |
Return the versioned name (i.e., the name inside the content) More... | |
MetadataObject & | setVersionedName (const Name &name) |
Set the versioned name. More... | |
Static Public Member Functions | |
static bool | isValidName (const Name &name) |
Check whether name can be a valid metadata name. More... | |
static NDN_CXX_NODISCARD Interest | makeDiscoveryInterest (Name name) |
Generate a discovery interest packet based on name . More... | |
Class for RDR-style metadata encoding/decoding.
The interest and data packets dealing with metadata (called "discovery interest" and "metadata", respectively) follow a specific format.
Realtime Data Retrieval (RDR) is a protocol for discovering the latest version number of a given data collection. There are two names in an RDR metadata object:
32=metadata
, as well as version and segment components. Definition at line 45 of file metadata-object.hpp.
|
default |
Create an empty metadata object.
|
explicit |
Construct a metadata object by decoding of the given Data packet.
tlv::Error | the Data is not a valid metadata packet |
Definition at line 33 of file metadata-object.cpp.
References ndn::tlv::ContentType_Blob, ndn::Block::get(), ndn::Data::getContent(), ndn::Data::getContentType(), ndn::Data::getName(), isValidName(), ndn::tlv::Name, NDN_THROW, ndn::Block::parse(), ndn::to_string(), ndn::Name::toUri(), and ndn::Name::wireDecode().
Data ndn::MetadataObject::makeData | ( | Name | discoveryInterestName, |
KeyChain & | keyChain, | ||
const ndn::security::SigningInfo & | si = KeyChain::getDefaultSigningInfo() , |
||
optional< uint64_t > | version = nullopt , |
||
time::milliseconds | freshnessPeriod = 10_ms |
||
) | const |
Create a Data packet representing this metadata object.
discoveryInterestName | the discovery Interest's name, which must end with a keyword name component 32=metadata |
keyChain | KeyChain to sign the Data |
si | signing parameters |
version | version number of metadata packet; if nullopt, use current Unix timestamp (in milliseconds) as the version number |
freshnessPeriod | freshness period of metadata packet |
tlv::Error | discoveryInterestName is not valid |
Definition at line 49 of file metadata-object.cpp.
References ndn::Name::appendSegment(), ndn::Name::appendVersion(), ndn::Name::empty(), ndn::KEYWORD_METADATA_COMP, NDN_THROW, ndn::Data::setContent(), ndn::Data::setFreshnessPeriod(), ndn::security::v2::KeyChain::sign(), ndn::Name::toUri(), and ndn::Name::wireEncode().
|
inline |
Return the versioned name (i.e., the name inside the content)
Definition at line 90 of file metadata-object.hpp.
MetadataObject & ndn::MetadataObject::setVersionedName | ( | const Name & | name | ) |
Set the versioned name.
Any metadata packet carries a versioned name in its payload where it shows the name and the latest version of a data stream. For instance, /ndn/test/FD%97%47%1E%6C
is a versioned name that shows the latest version of /ndn/test
.
Definition at line 71 of file metadata-object.cpp.
|
static |
Check whether name
can be a valid metadata name.
Definition at line 78 of file metadata-object.cpp.
References ndn::KEYWORD_METADATA_COMP.
Referenced by MetadataObject().
Generate a discovery interest packet based on name
.
name | prefix of data collection |
Definition at line 85 of file metadata-object.cpp.
References ndn::tlv::Interest, and ndn::KEYWORD_METADATA_COMP.