Debian Codegraph @

converter.go

raw symbols SCIP
1 package yamlscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/
2
3 import (
4 "github.com/zclconf/go-cty/ctyscip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/"
5 )
6
7 // ConverterConfig is used to configure a new converter, using NewConverter.
8 type ConverterConfigscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/ConverterConfig# struct {
9 // EncodeAsFlow, when set to true, causes Marshal to produce flow-style
10 // mapping and sequence serializations.
11 EncodeAsFlowscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/ConverterConfig#EncodeAsFlow. bool
12 }
13
14 // A Converter can marshal and unmarshal between cty values and YAML bytes.
15 //
16 // Because there are many different ways to map cty to YAML and vice-versa,
17 // a converter is configurable using the settings in ConverterConfig, which
18 // allow for a few different permutations of mapping to YAML.
19 //
20 // If you are just trying to work with generic, standard YAML, the predefined
21 // converter in Standard should be good enough.
22 type Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter# struct {
23 encodeAsFlowscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#encodeAsFlow. bool
24 }
25
26 // NewConverter creates a new Converter with the given configuration.
27 func NewConverterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/NewConverter().(config *ConverterConfigscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/ConverterConfig#) *Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter# {
28 return &Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#{
29 encodeAsFlowscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#encodeAsFlow.: config.EncodeAsFlowscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/ConverterConfig#EncodeAsFlow.,
30 }
31 }
32
33 // Standard is a predefined Converter that produces and consumes generic YAML
34 // using only built-in constructs that any other YAML implementation ought to
35 // understand.
36 var Standardscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Standard. *Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter# = NewConverterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/NewConverter().(&ConverterConfigscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/ConverterConfig#{})
37
38 // ImpliedType analyzes the given source code and returns a suitable type that
39 // it could be decoded into.
40 //
41 // For a converter that is using standard YAML rather than cty-specific custom
42 // tags, only a subset of cty types can be produced: strings, numbers, bools,
43 // tuple types, and object types.
44 func (c *Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#) ImpliedTypescip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#ImpliedType().(src []byte) (ctyscip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/Type#, error) {
45 return c.impliedTypescip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#impliedType().(src)
46 }
47
48 // Marshal serializes the given value into a YAML document, using a fixed
49 // mapping from cty types to YAML constructs.
50 //
51 // Note that unlike the function of the same name in the cty JSON package,
52 // this does not take a type constraint and therefore the YAML serialization
53 // cannot preserve late-bound type information in the serialization to be
54 // recovered from Unmarshal. Instead, any cty.DynamicPseudoType in the type
55 // constraint given to Unmarshal will be decoded as if the corresponding portion
56 // of the input were processed with ImpliedType to find a target type.
57 func (c *Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#) Marshalscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#Marshal().(v ctyscip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/Value#) ([]byte, error) {
58 return c.marshalscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#marshal().(v)
59 }
60
61 // Unmarshal reads the document found within the given source buffer
62 // and attempts to convert it into a value conforming to the given type
63 // constraint.
64 //
65 // An error is returned if the given source contains any YAML document
66 // delimiters.
67 func (c *Converterscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#) Unmarshalscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#Unmarshal().(src []byte, ty ctyscip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/.Typescip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/Type#) (ctyscip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/.Valuescip-go gomod github.com/zclconf/go-cty v1.0.0 `github.com/zclconf/go-cty/cty`/Value#, error) {
68 return c.unmarshalscip-go gomod github.com/zclconf/go-cty-yaml . `github.com/zclconf/go-cty-yaml`/Converter#unmarshal().(src, ty)
69 }