github.com/haraldrudell/parl@v0.4.176/yamlo/generic-yaml.go (about)

     1  /*
     2  © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package yamlo
     7  
     8  // GenericYaml is a wrapper for [yamlo.Unmarshaler] that allows the
     9  // yamlo package to unmarshal yaml to an unimported type
    10  type GenericYaml interface {
    11  	// Unmarshal updates [yamlo.Unmarshaler]’s value pointer with
    12  	// data from yaml
    13  	//	- yamlText is utf8-encoded binary data read from the yaml file
    14  	//	- yamlDictionaryKey is the name of the top-level dictionary-key
    15  	//		typically “options”
    16  	//	- hasData indicates that unmarshal succeeded and yamlDictionaryKey
    17  	//		was present
    18  	Unmarshal(yamlText []byte, yamlDictionaryKey string) (hasData bool, err error)
    19  	// VisitedReferencesMap returns a map of
    20  	// key: any-typed pointers to fields of u.y,
    21  	// value: lower-case field names
    22  	// - unmarshals yaml again to an any object and then
    23  	// builds the visited references map by comparing the unmarshaled object to the
    24  	// u.y struct-pointer
    25  	VisitedReferencesMap(yamlText []byte, yamlDictionaryKey string) (yamlVisistedReferences map[any]string, err error)
    26  	// YDump returns field names and values for the yaml value struct
    27  	YDump() (yamlVPrint string)
    28  }