// MarshalText lets Level implements the TextMarshaler interface used by encoding packages
3582
func (l Level) MarshalText() ([]byte, error) {
	var t []byte
	switch l {
	case LevelDebug:
		t = levelBytesDebug
	case LevelInfo:
		t = levelBytesInfo
	case LevelWarn:
		t = levelBytesWarn
	case LevelError:
		t = levelBytesError
	case LevelFatal:
		t = levelBytesFatal
	default:
		t = []byte(strconv.FormatInt(int64(l), 10))
	}
	return t, nil
}
76162
func (tf timeFormat) MarshalText() (text []byte, err error) {
	// The following code adapted from the standard library time.Time.Format
	// method. Using the same undocumented magic constant to extend the size
	// of the buffer as seen there.
	b := make([]byte, 0, len(tf.layout)+10)
	b = tf.time.AppendFormat(b, tf.layout)
	return b, nil
}
914962
func (t UnixTime) MarshalText() ([]byte, error) {
	cast := time.Time(t)
	return cast.MarshalText()
}
1142562
func (s DLSettings) MarshalText() ([]byte, error) {
	b, err := s.MarshalBinary()
	if err != nil {
		return nil, err
	}

	return []byte(hex.EncodeToString(b)), nil
}
1010
func (b Uint64) MarshalText() ([]byte, error) {
	buf := make([]byte, 2, 10)
	copy(buf, `0x`)
	buf = strconv.AppendUint(buf, uint64(b), 16)
	return buf, nil
}
1028273
func (b Big) MarshalText() ([]byte, error) {
	return []byte(EncodeBig((*big.Int)(&b))), nil
}
1069693
func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error {
	if err := p.writeStart(&start); err != nil {
		return err
	}
	text, err := val.MarshalText()
	if err != nil {
		return err
	}
	EscapeText(p, text)
	return p.writeEnd(start.Name)
}
1299229
func (id ULID) MarshalText() ([]byte, error) {
	ulid := make([]byte, EncodedSize)
	return ulid, id.MarshalTextTo(ulid)
}
979544
func MarshalTo(w io.Writer, v interface{}) error {
	rv := reflect.ValueOf(v)
	if rv.Kind() == reflect.Ptr {
		rv = rv.Elem()
	}

	var err error
	switch rv.Kind() {
	case reflect.Map:
		if m, ok := v.(map[string]string); ok {
			err = marshalMapTo(w, m)
			break
		}
		err = fmt.Errorf("not a map[string]string")
	case reflect.Struct:
		err = marshalStructTo(w, rv)
	default:
		err = fmt.Errorf("not a struct/map: %v", v)
	}
	return err
}
1044145
func (n ID) MarshalText() ([]byte, error) {
	return []byte(hex.EncodeToString(n[:])), nil
}
1004449
func (l *Level) UnmarshalText(text []byte) (err error) {
	if bytes.Equal(text, levelBytesDebug) {
		*l = LevelDebug
	} else if bytes.Equal(text, levelBytesInfo) {
		*l = LevelInfo
	} else if bytes.Equal(text, levelBytesWarn) {
		*l = LevelWarn
	} else if bytes.Equal(text, levelBytesError) {
		*l = LevelError
	} else if bytes.Equal(text, levelBytesFatal) {
		*l = LevelFatal
	} else {
		err = fmt.Errorf("Uknown level %v", string(text))
	}
	return
}
305907
func (v RawMessage) MarshalJSON() ([]byte, error) {
	if len(v) == 0 {
		return nullBytes, nil
	}
	return v, nil
}
1157528
func (t *Table) ToText(sep string) (*bytes.Buffer, error) {
	t.mu.RLock()
	defer t.mu.RUnlock()
	res, row := &bytes.Buffer{}, &bytes.Buffer{}
	res.WriteString(strings.Join(t.AvailableBindings, sep))
	res.WriteString("\n")
	for _, r := range t.Data {
		err := r.ToTextLine(row, t.AvailableBindings, sep)
		if err != nil {
			return nil, err
		}
		if _, err := res.Write(row.Bytes()); err != nil {
			return nil, err
		}
		if _, err := res.WriteString("\n"); err != nil {
			return nil, err
		}
		row.Reset()
	}
	return res, nil
}
1323856
func (m Map) UnmarshalText(text []byte) error {
	err := json.Unmarshal(text, &m)
	if err != nil {
		return errors.WithStack(err)
	}
	return nil
}
487067
func (m AppEUIMetadata) MarshalText() ([]byte, error) {
	return []byte(fmt.Sprintf("AppEUI %s", m.AppEUI)), nil
}
484408
func (du *DataURL) MarshalText() ([]byte, error) {
	buf := bytes.NewBuffer(nil)
	if _, err := du.WriteTo(buf); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
857886
func (h *UnprefixedHash) UnmarshalText(input []byte) error {
	return hexutil.UnmarshalFixedUnprefixedText("UnprefixedHash", input, h[:])
}