Class: ProtobufTlv

ProtobufTlv()

new ProtobufTlv()

ProtobufTlv has static methods to encode and decode an Protobuf Message object as NDN-TLV. The Protobuf tag value is used as the TLV type code. A Protobuf message is encoded/decoded as a nested TLV encoding. Protobuf types uint32, uint64 and enum are encoded/decoded as TLV nonNegativeInteger. (It is an error if an enum value is negative.) Protobuf types bytes and string are encoded/decoded as TLV bytes. The Protobuf type bool is encoded/decoded as a TLV boolean (a zero length value for True, omitted for False). The Protobuf type double is encoded/decoded as an 8-byte little-endian IEEE 754 double. Other Protobuf types are an error. Protobuf has no "outer" message type, so you need to put your TLV message inside an outer "typeless" message.
Source:

Methods

(static) _decodeFieldValue()

This is a helper for _decodeMessageValue. Decode a single field and return the value. Assume the field.type.name is not "message".
Source:

(static) decode(message, descriptor, input)

Decode the input as NDN-TLV and update the fields of the Protobuf message object.
Parameters:
Name Type Description
message ProtoBuf.Builder.Message The Protobuf message object. This does not first clear the object.
descriptor ProtoBuf.Reflect.T The reflection descriptor for the message. For example, if the message is of type "MyNamespace.MyMessage" then the descriptor is builder.lookup("MyNamespace.MyMessage").
input Blob | Buffer The buffer with the bytes to decode.
Source:

(static) encode(message, descriptor) → {Blob}

Encode the Protobuf message object as NDN-TLV. This calls message.encodeAB() to ensure that all required fields are present and raises an exception if not. (This does not use the result of toArrayBuffer().)
Parameters:
Name Type Description
message ProtoBuf.Builder.Message The Protobuf message object.
descriptor ProtoBuf.Reflect.T The reflection descriptor for the message. For example, if the message is of type "MyNamespace.MyMessage" then the descriptor is builder.lookup("MyNamespace.MyMessage").
Source:
Returns:
The encoded buffer in a Blob object.
Type
Blob

(static) toName(componentArray)

Return a Name made from the component array in a Protobuf message object, assuming that it was defined with "repeated bytes". For example: message Name { repeated bytes component = 8; }
Parameters:
Name Type Description
componentArray Array The array from the Protobuf message object representing the "repeated bytes" component array.
Source:
Returns:
A new Name.