ndn::util::Segmenter Class Reference

Utility class to segment an object into multiple Data packets. More...

#include <ndn-cxx/util/segmenter.hpp>

Public Member Functions

 Segmenter (KeyChain &keyChain, const security::SigningInfo &signingInfo)
 Constructor. More...
 
std::vector< std::shared_ptr< Data > > segment (span< const uint8_t > buffer, const Name &dataName, size_t maxSegmentSize, time::milliseconds freshnessPeriod, uint32_t contentType=tlv::ContentType_Blob)
 Splits a blob of bytes into one or more Data packets (segments). More...
 
std::vector< std::shared_ptr< Data > > segment (std::istream &input, const Name &dataName, size_t maxSegmentSize, time::milliseconds freshnessPeriod, uint32_t contentType=tlv::ContentType_Blob)
 Creates one or more Data packets (segments) with the bytes read from an input stream. More...
 

Detailed Description

Utility class to segment an object into multiple Data packets.

Definition at line 34 of file segmenter.hpp.

Constructor & Destructor Documentation

◆ Segmenter()

ndn::util::Segmenter::Segmenter ( KeyChain &  keyChain,
const security::SigningInfo signingInfo 
)

Constructor.

Parameters
keyChainKeyChain instance used for signing the packets.
signingInfoHow to sign the packets.

Definition at line 29 of file segmenter.cpp.

Member Function Documentation

◆ segment() [1/2]

std::vector< std::shared_ptr< Data > > ndn::util::Segmenter::segment ( span< const uint8_t >  buffer,
const Name dataName,
size_t  maxSegmentSize,
time::milliseconds  freshnessPeriod,
uint32_t  contentType = tlv::ContentType_Blob 
)

Splits a blob of bytes into one or more Data packets (segments).

Parameters
bufferContiguous range of bytes to divide into segments.
dataNameName prefix to use for the Data packets. A segment number will be appended to it.
maxSegmentSizeMaximum size of the Content element (payload) of each created Data packet.
freshnessPeriodThe FreshnessPeriod of created Data packets.
contentTypeThe ContentType of created Data packets.
Note
A minimum of one Data packet is always returned, even if buffer is empty.

Definition at line 36 of file segmenter.cpp.

◆ segment() [2/2]

std::vector< std::shared_ptr< Data > > ndn::util::Segmenter::segment ( std::istream &  input,
const Name dataName,
size_t  maxSegmentSize,
time::milliseconds  freshnessPeriod,
uint32_t  contentType = tlv::ContentType_Blob 
)

Creates one or more Data packets (segments) with the bytes read from an input stream.

Parameters
inputThe input stream. Reading stops when EOF is encountered.
dataNameName prefix to use for the Data packets. A segment number will be appended to it.
maxSegmentSizeMaximum size of the Content element (payload) of each created Data packet.
freshnessPeriodThe FreshnessPeriod of created Data packets.
contentTypeThe ContentType of created Data packets.
Note
A minimum of one Data packet is always returned, even if input is empty.

Definition at line 71 of file segmenter.cpp.