// MarshalText returns the string-representation of the UUID as a byte-array.
338427
func (u UUID) MarshalText() ([]byte, error) {
	/* Inlined UUID.String() implementation, cannot reuse the one from
	   UUID.String() as that cast will force an additional memory
	   allocation because current version the compiler (go 1.3.1) cannot
	   realize that the data pointer of the result of the UUID.String() call
	   can be moved to the byte-slice return. Speed difference from inlining
	   is about +20% */
	/* Equivalent code:
	   return []byte(u.String()), nil */
	/* NOTE: If this is changed, also look at the following methods:
	   UUID.MarshalJSON() and UUID.String() */
	b := [36]byte{}

	for i, n := range []int{
		0, 2, 4, 6,
		9, 11,
		14, 16,
		19, 21,
		24, 26, 28, 30, 32, 34,
	} {
		b[n] = halfbyte2hexchar[(u[i]>>4)&0x0f]
		b[n+1] = halfbyte2hexchar[u[i]&0x0f]
	}

	b[8] = '-'
	b[13] = '-'
	b[18] = '-'
	b[23] = '-'

	return b[:], nil
}
523025
func (e *pluginError) MarshalText() (text []byte, err error) {
	return []byte(e.cause.Error()), 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
}
677944
func MarshalBytes(in interface{}) (out []byte, err error) {
	bufferString := bytes.NewBuffer(out)
	if err := Marshal(in, bufferString); err != nil {
		return nil, err
	}
	return bufferString.Bytes(), nil
}
58763
func (n NullUUID) MarshalJSON() ([]byte, error) {
	if n.Valid {
		return n.UUID.MarshalJSON()
	} else {
		return nullByteString, nil
	}
}
1348857
func (t TextErr) MarshalText() ([]byte, error) {
	return []byte(t.Err.Error()), nil
}
852619
func (a UnprefixedAddress) MarshalText() ([]byte, error) {
	return []byte(hex.EncodeToString(a[:])), nil
}
812044
func (u *UUID) UnmarshalText(text []byte) (err error) {
	if len(text) < 32 {
		err = fmt.Errorf("uuid: UUID string too short: %s", text)
		return
	}

	t := text[:]
	braced := false

	if bytes.Equal(t[:9], urnPrefix) {
		t = t[9:]
	} else if t[0] == '{' {
		braced = true
		t = t[1:]
	}

	b := u[:]

	for i, byteGroup := range byteGroups {
		if i > 0 {
			if t[0] != '-' {
				err = fmt.Errorf("uuid: invalid string format")
				return
			}
			t = t[1:]
		}

		if len(t) < byteGroup {
			err = fmt.Errorf("uuid: UUID string too short: %s", text)
			return
		}

		if i == 4 && len(t) > byteGroup &&
			((braced && t[byteGroup] != '}') || len(t[byteGroup:]) > 1 || !braced) {
			err = fmt.Errorf("uuid: UUID string too long: %s", text)
			return
		}

		_, err = hex.Decode(b[:byteGroup/2], t[:byteGroup])
		if err != nil {
			return
		}

		t = t[byteGroup:]
		b = b[byteGroup/2:]
	}

	return
}
746267
func (k KeyDelta) MarshalJSON() ([]byte, error) {
	return json.Marshal(struct {
		Type DifferenceType `json:"type"`
		Name Keyword        `json:"name"`
		Old  string         `json:"old"`
		New  string         `json:"new"`
	}{
		Type: k.diff,
		Name: k.name,
		Old:  k.old,
		New:  k.new,
	})
}
895341
func (p PHYPayload) MarshalText() ([]byte, error) {
	b, err := p.MarshalBinary()
	if err != nil {
		return nil, err
	}
	return []byte(base64.StdEncoding.EncodeToString(b)), nil
}
1206988
func (u *UUID) UnmarshalText(text []byte) error {
	id := make([]byte, base64.StdEncoding.DecodedLen(len(text)))
	length, err := base64.StdEncoding.Decode(id, text)
	if err != nil {
		return err
	}
	if length != 16 {
		return ErrInvalidUUIDLength
	}
	copy((*u)[:], id[:16])
	return nil
}
1023570
func (d Duration) MarshalText() ([]byte, error) {
	if d == 0 {
		return nil, nil
	}

	out := "PT"
	if d < 0 {
		d *= -1
		out = "-" + out
	}

	h := time.Duration(d) / time.Hour
	m := time.Duration(d) % time.Hour / time.Minute
	s := time.Duration(d) % time.Minute / time.Second
	ns := time.Duration(d) % time.Second
	if h > 0 {
		out += fmt.Sprintf("%dH", h)
	}
	if m > 0 {
		out += fmt.Sprintf("%dM", m)
	}
	if s > 0 || ns > 0 {
		out += fmt.Sprintf("%d", s)
		if ns > 0 {
			out += strings.TrimRight(fmt.Sprintf(".%09d", ns), "0")
		}
		out += "S"
	}

	return []byte(out), nil
}
640789
func (f Field) MarshalText() (p []byte, err error) {
	return []byte(f.reference.String()), nil
}
353977
func (i HexOrDecimal64) MarshalText() ([]byte, error) {
	return []byte(fmt.Sprintf("%#x", uint64(i))), nil
}
1305199
func (bh *Header) MarshalText() ([]byte, error) {
	var buf bytes.Buffer
	if bh.Version != "" {
		if bh.GroupOrder == GroupUnspecified {
			fmt.Fprintf(&buf, "@HD\tVN:%s\tSO:%s", bh.Version, bh.SortOrder)
		} else {
			fmt.Fprintf(&buf, "@HD\tVN:%s\tSO:%s\tGO:%s", bh.Version, bh.SortOrder, bh.GroupOrder)
		}
		for _, tp := range bh.otherTags {
			fmt.Fprintf(&buf, "\t%s:%s", tp.tag, tp.value)
		}
		buf.WriteByte('\n')
	}
	for _, r := range bh.refs {
		fmt.Fprintf(&buf, "%s\n", r)
	}
	for _, rg := range bh.rgs {
		fmt.Fprintf(&buf, "%s\n", rg)
	}
	for _, p := range bh.progs {
		fmt.Fprintf(&buf, "%s\n", p)
	}
	for _, co := range bh.Comments {
		fmt.Fprintf(&buf, "@CO\t%s\n", co)
	}
	return buf.Bytes(), nil
}
856027
func (r *Rational) MarshalText() (b []byte, err error) {
	b = []byte(fmt.Sprintf("%d/%d", r.num, r.den))
	return
}
233839
func (c Code) MarshalText() ([]byte, error) {
	s, ok := _codeToString[c]
	if ok {
		return []byte(s), nil
	}
	return nil, fmt.Errorf("unknown code: %d", int(c))
}