ndn.encoding package
Introduction
The ndn.encoding package contains classes and functions
that help to encode and decode NDN Name, NameComponent, Data and Interest.
There are three parts of this package:
TLV elements: process TLV variables, Names and NameComponents.
TlvModel: design a general way to describe a TLV format. A TLV object can be described with a class derived from
TlvModel, with members of typeField.NDN Packet Fotmat v0.3: functions used to encode and parse Interest and Data packets in NDN Packet Format Spec 0.3.
FormalName and NonStrictName
To increase the flexibility, API in python-ndn accepts Name arguments in a wide range of formats,
i.e. NonStrictName, but returns an unified form, FormalName.
A Component is a NameComponent encoded in TLV format.
component = b'\x08\x09component'
A FormalName is a list of encoded Components.
formal_name = [bytearray(b'\x08\x06formal'), b'\x08\x04name']
A NonStrictName is any of below:
A URI string.
casual_name_1 = "/non-strict/8=name"
A list or iterator of Components, in the form of either encoded TLV or URI string.
casual_name_2 = [bytearray(b'\x08\x0anon-strict'), 'name'] casual_name_3 = (f'{x}' for x in range(3))
An encoded Name of type
bytes,bytearrayormemoryview.casual_name_4 = b'\x07\x12\x08\x0anon-strict\x08\x04name'