encoder

package
v0.0.0-...-dbcdf9e Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormatText is used to configure the Encoder to generate
	// its output in text format.
	FormatText = "text"

	// FormatJSON is used to configure the Encoder to generate
	// its output in JSON format.
	FormatJSON = "json"
)
View Source
const (
	// DefaultOutputDir is the default directory all files will be
	// written in when a custom directory is not specified.
	DefaultOutputDir = "./"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	// Encode takes a Certificate object, encodes it,
	// and returns a corresponding Result object.
	//
	// It returns a non-nil error in case it fails to
	// encode the given Certificate.
	Encode(cert.Certificate) (Result, error)
}

Encoder defines the operations each encoder implementation needs to satisfy.

func New

func New(opts Options) Encoder

New takes an Options object and returns a corresponding Encoder to satisfy the given Options.

type Options

type Options struct {
	// Format configures the output format of the encoder
	// (e.g. "text" or "json").
	Format string

	// WriteToDisk controls whether or not the resulting
	// artifact should be written to disk.
	WriteToDisk bool

	// OutputDir configures the directory in which files
	// whould be written when WriteToDisk is set to `true`.
	OutputDir string
}

Options configures the behavior of the different types of Encoder.

type Result

type Result struct {
	// Success is set to `true` when encoding is successful.
	Success bool

	// Artifacts will contain the names of files written
	// when the Encoder is configures to write to disk.
	Artifacts []string
}

Result contains information about the encoding results.

Jump to

Keyboard shortcuts

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