encoder

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_DEPTH = 10000

Variables

This section is empty.

Functions

func AddIndent

func AddIndent(b []byte) []byte

func RegisterEncoder

func RegisterEncoder[T any](fn EncoderFn)

Types

type Config

type Config struct {
	Scope scopes.Context
	// contains filtered or unexported fields
}

func (*Config) Marshal

func (c *Config) Marshal(v any) ([]byte, error)

func (*Config) MarshalCtx

func (c *Config) MarshalCtx(v any, ctx *ctx.Ctx) ([]byte, error)

func (*Config) MarshalPartial

func (c *Config) MarshalPartial(v any, fields []string, short bool) ([]byte, error)

func (*Config) MarshalPartialCtx

func (c *Config) MarshalPartialCtx(v any, fields []string, short bool, ctx *ctx.Ctx) ([]byte, error)

func (*Config) NewEncoder

func (c *Config) NewEncoder() *Encoder

func (*Config) Return

func (c *Config) Return(e *Encoder)

type Encoder

type Encoder struct {
	*ctx.Ctx
	// contains filtered or unexported fields
}

func (*Encoder) Context

func (e *Encoder) Context() scopes.Context

func (*Encoder) Encode

func (e *Encoder) Encode(v any) error

func (*Encoder) EncodeFloat

func (e *Encoder) EncodeFloat(v reflect.Value, bits int) error

func (*Encoder) EncodeMap

func (e *Encoder) EncodeMap(v reflect.Value, keyEnc, valueEnc EncoderFn) error

func (*Encoder) EncodePartial

func (e *Encoder) EncodePartial(v any, fields []string, short int) error

EncodePartial works like MarshalPartial but it will respect partial settings of the encoder If fields were set by MarshalPartial, it will preserve them. If you set short parameter to 1 it will use short encoding for the fields, 0 will not use short encoding, -1 will preserve the current setting If you pass fields, their names will be prepended with the current path of the encoder

func (*Encoder) EncodeSlice

func (e *Encoder) EncodeSlice(v reflect.Value, valueEnc EncoderFn) (err error)

func (*Encoder) Error

func (e *Encoder) Error(msg string) error

func (*Encoder) ErrorF

func (e *Encoder) ErrorF(format string, args ...interface{}) error

func (*Encoder) GetCurrentPath

func (e *Encoder) GetCurrentPath() string

GetCurrentPath will return the path of the current field being encoded if encoder is created by MarshalPartial Otherwise it will return an empty string

func (*Encoder) GetFields

func (e *Encoder) GetFields() []string

GetFields will return the fields that should be encoded if encoder is created by MarshalPartial Otherwise it will return an empty slice

func (*Encoder) Marshal

func (e *Encoder) Marshal(v any) ([]byte, error)

func (*Encoder) MarshalPartial

func (e *Encoder) MarshalPartial(v any, fields []string, short bool) ([]byte, error)

func (*Encoder) Reset

func (e *Encoder) Reset()

func (*Encoder) Write

func (e *Encoder) Write(b []byte)

func (*Encoder) WriteByte

func (e *Encoder) WriteByte(b byte)

func (*Encoder) WriteString

func (e *Encoder) WriteString(s string)

type EncoderFn

type EncoderFn func(*Encoder, reflect.Value) error

type Marshaler

type Marshaler interface {
	MarshalBlaze(e *Encoder) error
}

Jump to

Keyboard shortcuts

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