Skip to content

Commit

Permalink
doc: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jszwec committed Feb 19, 2023
1 parent 8a945ba commit 0805d99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ func (d *Decoder) Register(f any) {
}

// WithUnmarshalers sets the provided Unmarshalers for the decoder.
//
// WithUnmarshalers is based on the encoding/json proposal:
// https://github.com/golang/go/issues/5901.
func (d *Decoder) WithUnmarshalers(u *Unmarshalers) {
d.funcMap = u.funcMap
d.ifaceFuncs = u.ifaceFuncs
Expand Down Expand Up @@ -580,6 +583,9 @@ func indirect(v reflect.Value) reflect.Value {
}

// Unmarshalers stores custom unmarshal functions. Unmarshalers is immutable.
//
// Unmarshalers are based on the encoding/json proposal:
// https://github.com/golang/go/issues/5901.
type Unmarshalers struct {
funcMap map[reflect.Type]func([]byte, any) error
ifaceFuncs []ifaceDecodeFunc
Expand Down
7 changes: 7 additions & 0 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func (enc *Encoder) SetHeader(header []string) {
enc.header = cp
}

// WithMarshalers sets the provided Marshalers for the encoder.
//
// WithMarshalers are based on the encoding/json proposal:
// https://github.com/golang/go/issues/5901.
func (enc *Encoder) WithMarshalers(m *Marshalers) {
enc.funcMap = m.funcMap
enc.ifaceFuncs = m.ifaceFuncs
Expand Down Expand Up @@ -420,6 +424,9 @@ func (e *Encoder) cache(typ reflect.Type) ([]encField, []byte, []int, []string,
}

// Marshalers stores custom unmarshal functions. Marshalers are immutable.
//
// Marshalers are based on the encoding/json proposal:
// https://github.com/golang/go/issues/5901.
type Marshalers struct {
funcMap map[reflect.Type]marshalFunc
ifaceFuncs []marshalFunc
Expand Down

0 comments on commit 0805d99

Please sign in to comment.