somegraph

package
v0.0.0-...-9351530 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SomeGraphFromJSONable

func SomeGraphFromJSONable(
	value interface{},
	ref string,
	target *SomeGraph,
	errors *Errors)

SomeGraphFromJSONable parses SomeGraph from a JSONable value.

If there are any errors, the state of target is undefined.

SomeGraphFromJSONable requires:

  • target != nil
  • errors != nil
  • errors.Empty()

func SomeGraphToJSONable

func SomeGraphToJSONable(
	instance *SomeGraph) (
	target map[string]interface{}, err error)

SomeGraph converts the instance to a JSONable representation.

SomeGraph requires:

  • instance != nil

SomeGraph ensures:

  • (err == nil && target != nil) || (err != nil && target == nil)

func WithOptionalFromJSONable

func WithOptionalFromJSONable(
	value interface{},
	id string,
	ref string,
	target *WithOptional,
	errors *Errors)

WithOptionalFromJSONable parses WithOptional from a JSONable value.

If there are any errors, the state of the target is undefined.

WithOptionalFromJSONable requires:

  • target != nil
  • errors != nil
  • errors.Empty()

func WithOptionalToJSONable

func WithOptionalToJSONable(
	instance *WithOptional) (
	target map[string]interface{})

WithOptionalToJSONable converts the instance to a JSONable representation.

WithOptionalToJSONable requires:

  • instance != nil

WithOptionalToJSONable ensures:

  • target != nil

Types

type Error

type Error struct {
	// references the cause (e.g., a reference path).
	Ref string

	// describes the error.
	Message string
}

Error represents a parsing error.

type Errors

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

Errors collects parsing errors capped at a certain quantity.

If the capacity is full, the subsequent surplus errors are ignored.

func NewErrors

func NewErrors(cap uint64) (e *Errors)

NewErrors initializes a new error container with the capacity `cap`.

The capacity of 0 means infinite capacity.

func (*Errors) Add

func (e *Errors) Add(ref string, message string)

Add inserts the error into the container.

ref indicates the cause (e.g., as a reference path). message describes the error. If the capacity is full, the subsequent surplus errors are ignored.

func (*Errors) Empty

func (e *Errors) Empty() bool

Empty indicates whether no parsing errors occurred.

func (*Errors) Full

func (e *Errors) Full() bool

Full indicates whether the container is full.

func (*Errors) Values

func (e *Errors) Values() []Error

Values gets the contained errors.

The caller should not modify the returned errors.

type SomeGraph

type SomeGraph struct {
	// registers instances of WithOptional.
	WithOptionals map[string]*WithOptional
}

SomeGraph defines some object graph.

type WithOptional

type WithOptional struct {
	// identifies the instance
	ID string

	// defines an optional property.
	SomeText *string
}

WithOptional defines a class with an optional property.

Jump to

Keyboard shortcuts

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