ctyencoder

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionEncoder

type CollectionEncoder[T any] interface {
	// Will be called for each element in the collection.
	Add(k cty.Value, v T) diagnostics.Diag
	// Will be called after all elements are added.
	Encode() (T, diagnostics.Diag)
}

CollectionEncoder is an interface for encoding cty collections into a specific type.

type Encoder

type Encoder[T any] struct {
	// Most general encoder, used when no other encoder is applicable.
	// This includes primitives, unknown types and nulls.
	EncodeVal        func(val cty.Value) (T, diagnostics.Diag)
	EncodePluginData func(val plugin.Data) (T, diagnostics.Diag)
	MapEncoder       func(val cty.Value) (CollectionEncoder[T], diagnostics.Diag)
	ObjectEncoder    func(val cty.Value) (CollectionEncoder[T], diagnostics.Diag)
	ListEncoder      func(val cty.Value) (CollectionEncoder[T], diagnostics.Diag)
	TupleEncoder     func(val cty.Value) (CollectionEncoder[T], diagnostics.Diag)
	SetEncoder       func(val cty.Value) (CollectionEncoder[T], diagnostics.Diag)
}

Encoder is a generic interface for encoding cty values into a specific type.

func (*Encoder[T]) Encode

func (e *Encoder[T]) Encode(path cty.Path, val cty.Value) (result T, diags diagnostics.Diag)

Jump to

Keyboard shortcuts

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