new TlvStructureDecoder()
A TlvStructureDecoder finds the end of an NDN-TLV element, even if the
element is supplied in parts.
Create and initialize a TlvStructureDecoder.
Methods
findElementEnd(input) → {boolean}
Continue scanning input starting from this.offset_ to find the element end.
If the end of the element which started at offset 0 is found, this returns
true and getOffset() is the length of the element. Otherwise, this returns
false which means you should read more into input and call again.
Parameters:
Name | Type | Description |
---|---|---|
input |
Buffer | The input buffer. You have to pass in input each time because the buffer could be reallocated. |
Returns:
true if found the element end, false if not.
- Type
- boolean
getOffset() → {number}
Get the current offset into the input buffer.
Returns:
The offset.
- Type
- number
seek(offset)
Set the offset into the input, used for the next read.
Parameters:
Name | Type | Description |
---|---|---|
offset |
number | The new offset. |