parsing

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterReader

func RegisterReader(format Format, fn NewReaderFn)

RegisterReader registers a new reader for the format.

func RegisterWriter

func RegisterWriter(format Format, fn NewWriterFn)

RegisterWriter registers a new writer for the format.

Types

type DocumentSeparator

type DocumentSeparator interface {
	// Separator returns the document separator.
	Separator() []byte
}

DocumentSeparator is an interface that can be implemented by writers to allow for custom document separators.

type Format

type Format string

Format represents a file format.

func RegisteredReaders

func RegisteredReaders() []Format

RegisteredReaders returns a list of registered readers.

func RegisteredWriters

func RegisteredWriters() []Format

RegisteredWriters returns a list of registered writers.

func (Format) NewReader

func (f Format) NewReader(options ReaderOptions) (Reader, error)

NewReader creates a new reader for the format.

func (Format) NewWriter

func (f Format) NewWriter(options WriterOptions) (Writer, error)

NewWriter creates a new writer for the format.

func (Format) String

func (f Format) String() string

String returns the string representation of the format.

type NewReaderFn

type NewReaderFn func(options ReaderOptions) (Reader, error)

NewReaderFn is a function that creates a new reader.

type NewWriterFn

type NewWriterFn func(options WriterOptions) (Writer, error)

NewWriterFn is a function that creates a new writer.

type Reader

type Reader interface {
	// Read reads a value from a byte slice.
	Read([]byte) (*model.Value, error)
}

Reader reads a value from a byte slice.

type ReaderOptions

type ReaderOptions struct {
	Ext map[string]string
}

func DefaultReaderOptions

func DefaultReaderOptions() ReaderOptions

DefaultReaderOptions returns the default reader options.

type Writer

type Writer interface {
	// Write writes a value to a byte slice.
	Write(*model.Value) ([]byte, error)
}

Writer writes a value to a byte slice.

func MultiDocumentWriter

func MultiDocumentWriter(w Writer) Writer

MultiDocumentWriter is a writer that can write multiple documents.

type WriterOptions

type WriterOptions struct {
	Compact bool
	Indent  string
	Ext     map[string]string
}

func DefaultWriterOptions

func DefaultWriterOptions() WriterOptions

DefaultWriterOptions returns the default writer options.

Directories

Path Synopsis
d

Jump to

Keyboard shortcuts

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