gen_basic

package
v0.0.0-...-d1ba03b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Code generated by ndn tlv codegen DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeMetaInfo

type FakeMetaInfo struct {
	//+field:natural
	Number uint64 `tlv:"0x18"`
	//+field:time
	Time time.Duration `tlv:"0x19"`
	//+field:binary
	Binary []byte `tlv:"0x1a"`
}

func ParseFakeMetaInfo

func ParseFakeMetaInfo(reader enc.WireView, ignoreCritical bool) (*FakeMetaInfo, error)

Parses encoded metadata into a FakeMetaInfo instance from a WireView, with an option to ignore critical fields during parsing.

func (*FakeMetaInfo) Bytes

func (value *FakeMetaInfo) Bytes() []byte

Returns the concatenated byte slice of the encoded metadata information.

func (*FakeMetaInfo) Encode

func (value *FakeMetaInfo) Encode() enc.Wire

Encodes the FakeMetaInfo into its wire format using a FakeMetaInfoEncoder for transmission or storage.

type FakeMetaInfoEncoder

type FakeMetaInfoEncoder struct {
	Length uint
}

func (*FakeMetaInfoEncoder) Encode

func (encoder *FakeMetaInfoEncoder) Encode(value *FakeMetaInfo) enc.Wire

Encodes a `FakeMetaInfo` object into a byte slice using the encoder's `EncodeInto` method and wraps the result in an `enc.Wire` structure for transmission or storage.

func (*FakeMetaInfoEncoder) EncodeInto

func (encoder *FakeMetaInfoEncoder) EncodeInto(value *FakeMetaInfo, buf []byte)

Encodes a FakeMetaInfo struct into a TLV (Type-Length-Value) binary format in the provided buffer, including the Number (type 24), Time in milliseconds (type 25), and optional Binary data (type 26) fields.

func (*FakeMetaInfoEncoder) Init

func (encoder *FakeMetaInfoEncoder) Init(value *FakeMetaInfo)

Calculates the total length required to encode the FakeMetaInfo fields (Number, Time, and optional Binary) in a TLV format, including type markers and variable-length encodings, and sets the result on the encoder.

type FakeMetaInfoParsingContext

type FakeMetaInfoParsingContext struct {
}

func (*FakeMetaInfoParsingContext) Init

func (context *FakeMetaInfoParsingContext) Init()

Initializes the fake metadata parsing context to a default state, preparing it for test scenarios involving metadata parsing operations.

func (*FakeMetaInfoParsingContext) Parse

func (context *FakeMetaInfoParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*FakeMetaInfo, error)

Parses TLV-encoded MetaInfo data into a FakeMetaInfo struct, requiring Number and Time fields, with optional Binary data and configurable handling of critical fields.

type FixedUintField

type FixedUintField struct {
	//+field:fixedUint:byte
	Byte byte `tlv:"0x01"`
	//+field:fixedUint:uint32:optional
	U32 optional.Optional[uint32] `tlv:"0x02"`
	//+field:fixedUint:uint64:optional
	U64 optional.Optional[uint64] `tlv:"0x03"`
	//+field:byte
	BytePtr *byte `tlv:"0x04"`
}

func ParseFixedUintField

func ParseFixedUintField(reader enc.WireView, ignoreCritical bool) (*FixedUintField, error)

Parses a fixed unsigned integer field from the provided encoded data using a parsing context, returning the parsed field and any encountered error.

func (*FixedUintField) Bytes

func (value *FixedUintField) Bytes() []byte

Returns the concatenated byte representation of the encoded fixed unsigned integer field.

func (*FixedUintField) Encode

func (value *FixedUintField) Encode() enc.Wire

Encodes the FixedUintField value into a wire format by initializing and executing a FixedUintFieldEncoder.

type FixedUintFieldEncoder

type FixedUintFieldEncoder struct {
	Length uint
}

func (*FixedUintFieldEncoder) Encode

func (encoder *FixedUintFieldEncoder) Encode(value *FixedUintField) enc.Wire

Encodes a fixed-size unsigned integer field into a byte slice of length specified by the encoder and returns it as an NDN wire format structure.

func (*FixedUintFieldEncoder) EncodeInto

func (encoder *FixedUintFieldEncoder) EncodeInto(value *FixedUintField, buf []byte)

Encodes the FixedUintField into the provided buffer using a TLV (Type-Length-Value) format, including optional U32, U64, and BytePtr fields when present.

func (*FixedUintFieldEncoder) Init

func (encoder *FixedUintFieldEncoder) Init(value *FixedUintField)

Initializes the encoder's length by calculating the total size required to encode the FixedUintField, accounting for mandatory overhead and optional fields (U32, U64, BytePtr) when present.

type FixedUintFieldParsingContext

type FixedUintFieldParsingContext struct {
}

func (*FixedUintFieldParsingContext) Init

func (context *FixedUintFieldParsingContext) Init()

Initializes the parsing context for fixed unsigned integer fields, serving as a base method that may be overridden by subclasses to provide specific initialization logic.

func (*FixedUintFieldParsingContext) Parse

func (context *FixedUintFieldParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*FixedUintField, error)

Parses a binary-encoded FixedUintField structure, decoding required and optional unsigned integer fields (Byte, U32, U64, BytePtr) based on TLV-type identifiers, with critical field validation controlled by the ignoreCritical flag.

type Markers

type Markers struct {

	//+field:wire
	Wire enc.Wire `tlv:"0x01"`

	//+field:name
	Name enc.Name `tlv:"0x02"`
	// contains filtered or unexported fields
}

+tlv-model:private,ordered

func ParseMarkers

func ParseMarkers(buf []byte, arg int) *Markers

Parses a byte buffer into a Markers structure using the provided argument as parsing context, returning the result only if the entire buffer is successfully consumed without errors.

func (*Markers) Encode

func (m *Markers) Encode(arg int) []byte

Encodes the Markers into a byte slice using the provided argument, validating that the encoded data has correct start and end markers before returning the result.

type MarkersEncoder

type MarkersEncoder struct {
	Length uint

	Wire_length uint

	Name_length uint
	// contains filtered or unexported fields
}

func (*MarkersEncoder) Encode

func (encoder *MarkersEncoder) Encode(value *Markers) enc.Wire

Encodes the provided *Markers value into a byte slice of the encoder's predefined length and returns it as a single-element Wire structure.

func (*MarkersEncoder) EncodeInto

func (encoder *MarkersEncoder) EncodeInto(value *Markers, buf []byte)

Encodes the provided *Markers value into the given byte buffer using a TLV (Type-Length-Value) format, with separate encoding for Wire and Name fields, marking their start and end positions in the encoder.

func (*MarkersEncoder) Init

func (encoder *MarkersEncoder) Init(value *Markers)

Initializes the encoder by calculating the total encoded length of the Markers structure, including TLV-encoded Wire and Name fields, and sets start/end markers for subsequent encoding operations.

type MarkersParsingContext

type MarkersParsingContext struct {
	// contains filtered or unexported fields
}

func (*MarkersParsingContext) Init

func (context *MarkersParsingContext) Init()

Initializes the parsing context, but currently does nothing as the implementation is empty.

func (*MarkersParsingContext) Parse

func (context *MarkersParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*Markers, error)

Parses binary wire format into a Markers structure, handling specific fields (Wire, Name) and tracking start/end positions in context, with optional critical field tolerance.

type NoCopyStruct

type NoCopyStruct struct {
	//+field:wire
	Wire1 enc.Wire `tlv:"0x01"`
	//+field:natural
	Number uint64 `tlv:"0x02"`
	//+field:wire
	Wire2 enc.Wire `tlv:"0x03"`
}

+tlv-model:nocopy

func ParseNoCopyStruct

func ParseNoCopyStruct(reader enc.WireView, ignoreCritical bool) (*NoCopyStruct, error)

Parses a NoCopyStruct from the provided WireView reader, using the specified flag to determine whether to ignore critical fields during parsing.

func (*NoCopyStruct) Bytes

func (value *NoCopyStruct) Bytes() []byte

Returns the concatenated byte slice representation of the encoded NoCopyStruct.

func (*NoCopyStruct) Encode

func (value *NoCopyStruct) Encode() enc.Wire

Encodes the NoCopyStruct value into its wire representation using the NoCopyStructEncoder.

type NoCopyStructEncoder

type NoCopyStructEncoder struct {
	Length uint

	Wire1_length uint

	Wire2_length uint
	// contains filtered or unexported fields
}

func (*NoCopyStructEncoder) Encode

func (encoder *NoCopyStructEncoder) Encode(value *NoCopyStruct) enc.Wire

Encodes a NoCopyStruct into a non-copying wire representation by pre-allocating a byte slice according to the encoder's wirePlan and populating it with the struct's data.

func (*NoCopyStructEncoder) EncodeInto

func (encoder *NoCopyStructEncoder) EncodeInto(value *NoCopyStruct, wire enc.Wire)

Encodes a NoCopyStruct into a wire format by sequentially writing type markers, encoded lengths, and field values (Wire1, Number, Wire2) into a pre-allocated slice of byte buffers, avoiding data copying where possible.

func (*NoCopyStructEncoder) Init

func (encoder *NoCopyStructEncoder) Init(value *NoCopyStruct)

Initializes a NoCopyStructEncoder with the provided NoCopyStruct value, calculating the total encoded length and constructing a wire layout plan for efficient encoding of the struct's fields (Wire1, Number, and Wire2) without data copying.

type NoCopyStructParsingContext

type NoCopyStructParsingContext struct {
}

func (*NoCopyStructParsingContext) Init

func (context *NoCopyStructParsingContext) Init()

Initializes the NoCopyStructParsingContext for parsing operations that avoid data copying.

func (*NoCopyStructParsingContext) Parse

func (context *NoCopyStructParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*NoCopyStruct, error)

Parses a binary wire-format structure into a NoCopyStruct, handling required 'Number' (as uint64) and optional 'Wire1/Wire2' fields, with critical-type validation controlled by ignoreCritical.

type OptField

type OptField struct {
	//+field:natural:optional
	Number optional.Optional[uint64] `tlv:"0x18"`
	//+field:time:optional
	Time optional.Optional[time.Duration] `tlv:"0x19"`
	//+field:binary
	Binary []byte `tlv:"0x1a"`
	//+field:bool
	Bool bool `tlv:"0x30"`
}

func ParseOptField

func ParseOptField(reader enc.WireView, ignoreCritical bool) (*OptField, error)

Parses a TLV-encoded optional field from the provided wire format reader, using a parsing context and optionally ignoring critical fields if specified.

func (*OptField) Bytes

func (value *OptField) Bytes() []byte

Returns the byte representation of the optional field by encoding its value and concatenating the resulting byte slices.

func (*OptField) Encode

func (value *OptField) Encode() enc.Wire

Encodes the OptField value into a wire-format representation using an OptFieldEncoder for serialization.

type OptFieldEncoder

type OptFieldEncoder struct {
	Length uint
}

func (*OptFieldEncoder) Encode

func (encoder *OptFieldEncoder) Encode(value *OptField) enc.Wire

Encodes the provided optional field into its wire format byte slice using the encoder's specified length and returns it wrapped in a Wire structure.

func (*OptFieldEncoder) EncodeInto

func (encoder *OptFieldEncoder) EncodeInto(value *OptField, buf []byte)

Encodes an optional field (OptField) into a binary buffer using a TLV (Type-Length-Value) format, handling numeric, time, binary, and boolean values with distinct type codes (24, 25, 26, 48) and variable-length encoding.

func (*OptFieldEncoder) Init

func (encoder *OptFieldEncoder) Init(value *OptField)

Calculates the total encoded length for an optional field encoder by summing the TLV-encoded sizes of present fields (Number, Time, Binary, Bool) in the provided OptField.

type OptFieldParsingContext

type OptFieldParsingContext struct {
}

func (*OptFieldParsingContext) Init

func (context *OptFieldParsingContext) Init()

Initializes the optional field parsing context, intended to be overridden by subclasses for custom setup.

func (*OptFieldParsingContext) Parse

func (context *OptFieldParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*OptField, error)

Parses a wire-encoded TLV structure into an OptField, handling Number (type 24), Time (type 25), Binary (type 26), and Bool (type 48) fields while respecting criticality and defaulting unset fields.

type StrField

type StrField struct {
	//+field:string
	Str1 string `tlv:"0x01"`
	//+field:string:optional
	Str2 optional.Optional[string] `tlv:"0x02"`
}

func ParseStrField

func ParseStrField(reader enc.WireView, ignoreCritical bool) (*StrField, error)

Parses a string field from wire-format data, with an option to ignore critical fields that cannot be parsed.

func (*StrField) Bytes

func (value *StrField) Bytes() []byte

"Returns the byte representation of the string field by encoding its value and concatenating the resulting byte slices."

func (*StrField) Encode

func (value *StrField) Encode() enc.Wire

Encodes the string field value into a wire format using a StrFieldEncoder.

type StrFieldEncoder

type StrFieldEncoder struct {
	Length uint
}

func (*StrFieldEncoder) Encode

func (encoder *StrFieldEncoder) Encode(value *StrField) enc.Wire

Encodes a string field into a byte slice of the specified length, returning it as a wire structure.

func (*StrFieldEncoder) EncodeInto

func (encoder *StrFieldEncoder) EncodeInto(value *StrField, buf []byte)

Encodes a StrField struct into a binary buffer using a TLV (Type-Length-Value) format, where Str1 is required (tag 1) and Str2 is optional (tag 2) with presence indicated by inclusion.

func (*StrFieldEncoder) Init

func (encoder *StrFieldEncoder) Init(value *StrField)

Calculates the total encoded length of a StrField, including mandatory Str1 and optional Str2, and sets it on the encoder for subsequent serialization.

type StrFieldParsingContext

type StrFieldParsingContext struct {
}

func (*StrFieldParsingContext) Init

func (context *StrFieldParsingContext) Init()

Initializes the string field parsing context with default settings.

func (*StrFieldParsingContext) Parse

func (context *StrFieldParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*StrField, error)

Parses a TLV-encoded StrField from the provided WireView reader, handling required fields Str1 (type 1) and optional Str2 (type 2), with critical field validation controlled by ignoreCritical.

type WireNameField

type WireNameField struct {
	//+field:wire
	Wire enc.Wire `tlv:"0x01"`
	//+field:name
	Name enc.Name `tlv:"0x02"`
}

func ParseWireNameField

func ParseWireNameField(reader enc.WireView, ignoreCritical bool) (*WireNameField, error)

Parses a wire-encoded name field into a WireNameField structure, optionally ignoring critical TLV elements based on the ignoreCritical flag.

func (*WireNameField) Bytes

func (value *WireNameField) Bytes() []byte

Returns the wire-encoded byte slice representation of the name field by concatenating its encoded components.

func (*WireNameField) Encode

func (value *WireNameField) Encode() enc.Wire

Encodes the WireNameField into a binary wire format for use in NDN protocol messages.

type WireNameFieldEncoder

type WireNameFieldEncoder struct {
	Length uint

	Wire_length uint
	Name_length uint
}

func (*WireNameFieldEncoder) Encode

func (encoder *WireNameFieldEncoder) Encode(value *WireNameField) enc.Wire

Encodes the provided WireNameField into a byte slice of the encoder's specified length, returning a single-element Wire slice containing the encoded bytes.

func (*WireNameFieldEncoder) EncodeInto

func (encoder *WireNameFieldEncoder) EncodeInto(value *WireNameField, buf []byte)

Encodes a WireNameField into a binary buffer using TLV (Type-Length-Value) format, writing encoded Wire and Name components sequentially with type tags 1 and 2 respectively when non-nil.

func (*WireNameFieldEncoder) Init

func (encoder *WireNameFieldEncoder) Init(value *WireNameField)

Initializes the WireNameFieldEncoder by calculating the total encoded length of the provided WireNameField, summing the TLV-encoded sizes of Wire (raw bytes) and Name (NDN name components).

type WireNameFieldParsingContext

type WireNameFieldParsingContext struct {
}

func (*WireNameFieldParsingContext) Init

func (context *WireNameFieldParsingContext) Init()

Initializes the wire name field parsing context, currently serving as a placeholder with no implementation.

func (*WireNameFieldParsingContext) Parse

func (context *WireNameFieldParsingContext) Parse(reader enc.WireView, ignoreCritical bool) (*WireNameField, error)

Parses TLV-encoded name field data into a `WireNameField` struct, extracting either raw wire format bytes or parsed Name components, with optional support for ignoring critical unrecognized fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL