TLV Variables
- ndn.encoding.tlv_type.BinaryStr
A binary string is any of
bytes,bytearray,memoryview.alias of
bytes|bytearray|memoryview
- ndn.encoding.tlv_type.FormalName
A FormalName is a list of encoded Components.
alias of
List[bytes|bytearray|memoryview]
- ndn.encoding.tlv_type.NonStrictName
A NonStrictName is any of below:
A URI string.
A list or iterator of Components, in the form of either encoded TLV or URI string.
An encoded Name of type
bytes,bytearrayormemoryview.
See also FormalName and NonStrictName
alias of
Iterable[bytes|bytearray|memoryview|str] |str|bytes|bytearray|memoryview
- ndn.encoding.tlv_type.VarBinaryStr
A variant binary string is a
bytearrayor a non-readonlymemoryview.alias of
bytearray|memoryview
- ndn.encoding.tlv_type.is_binary_str(var)
Check whether var is of type BinaryStr.
- Parameters:
var – The variable to check.
- Returns:
Trueif var is aBinaryStr.
- ndn.encoding.tlv_var.get_tl_num_size(val)
Calculate the length of a TL variable.
- Parameters:
val (
int) – an integer standing for Type or Length.- Return type:
int- Returns:
The length of var.
- ndn.encoding.tlv_var.pack_uint_bytes(val)
Pack an non-negative integer value into bytes
- Parameters:
val (
int) – the integer.- Return type:
bytes- Returns:
the buffer.
- ndn.encoding.tlv_var.parse_and_check_tl(wire, expected_type)
Parse Type and Length, and then check:
If the Type equals expected_type;
If the Length equals the length of wire.
- Parameters:
wire (
Union[bytes,bytearray,memoryview]) – the TLV encoded wire.expected_type (
int) – expected Type.
- Return type:
memoryview- Returns:
a pointer to the memory of Value.
- ndn.encoding.tlv_var.parse_tl_num(buf, offset=0)
Parse a Type or Length variable from a buffer.
- Parameters:
buf (
Union[bytes,bytearray,memoryview]) – the buffer.offset (
int) – the starting offset.
- Return type:
(
int,int)- Returns:
a pair (value, size parsed).
- async ndn.encoding.tlv_var.read_tl_num_from_stream(reader, bio)
Read a Type or Length variable from a StreamReader.
- Parameters:
reader (
StreamReader) – the StreamReader.bio (
BytesIO) – the BytesIO to write whatever is read from the stream.
- Return type:
int- Returns:
the value read.
- ndn.encoding.tlv_var.write_tl_num(val, buf, offset=0)
Write a Type or Length value into a buffer.
- Parameters:
val (
int) – the value.buf (
Union[bytearray,memoryview]) – the buffer.offset (
int) – the starting offset.
- Return type:
int- Returns:
the encoded length.