encoding

package
v0.6.0-0.dev Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detect

func Detect(v cue.Value) (i build.Interpretation)

Detect detects the interpretation.

Types

type Config

type Config struct {
	Mode filetypes.Mode

	// Out specifies an overwrite destination.
	Out    io.Writer
	Stdin  io.Reader
	Stdout io.Writer

	PkgName string // package name for files to generate

	Force     bool // overwrite existing files
	Strict    bool
	Stream    bool // potentially write more than one document per file
	AllErrors bool

	Schema cue.Value // used for schema-based decoding

	EscapeHTML    bool
	InlineImports bool // expand references to non-core imports
	ProtoPath     []string
	Format        []format.Option
	ParseFile     func(name string, src interface{}) (*ast.File, error)
}

type Decoder

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

func NewDecoder

func NewDecoder(f *build.File, cfg *Config) *Decoder

NewDecoder returns a stream of non-rooted data expressions. The encoding type of f must be a data type, but does not have to be an encoding that can stream. stdin is used in case the file is "-".

func (*Decoder) Close

func (i *Decoder) Close()

func (*Decoder) Done

func (i *Decoder) Done() bool

func (*Decoder) Err

func (i *Decoder) Err() error

func (*Decoder) File

func (i *Decoder) File() *ast.File

func (*Decoder) Filename

func (i *Decoder) Filename() string

func (*Decoder) ID

func (i *Decoder) ID() string

ID returns a canonical identifier for the decoded object or "" if no such identifier could be found.

func (*Decoder) Index

func (i *Decoder) Index() int

func (*Decoder) Interpretation added in v0.2.0

func (i *Decoder) Interpretation() build.Interpretation

Interpretation returns the current interpretation detected by Detect.

func (*Decoder) Next

func (i *Decoder) Next()

type Encoder

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

An Encoder converts CUE to various file formats, including CUE itself. An Encoder allows

func NewEncoder

func NewEncoder(f *build.File, cfg *Config) (*Encoder, error)

NewEncoder writes content to the file with the given specification.

func (Encoder) Close

func (e Encoder) Close() error

func (*Encoder) Encode

func (e *Encoder) Encode(v cue.Value) error

func (*Encoder) EncodeFile

func (e *Encoder) EncodeFile(f *ast.File) error

func (*Encoder) EncodeInstance added in v0.3.0

func (e *Encoder) EncodeInstance(v *cue.Instance) error

EncodeInstance is as Encode, but stores instance information. This should all be retrievable from the value itself.

func (*Encoder) IsConcrete added in v0.3.0

func (e *Encoder) IsConcrete() bool

IsConcrete reports whether the output is required to be concrete.

INTERNAL ONLY: this is just to work around a problem related to issue #553 of catching errors ony after syntax generation, dropping line number information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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