go_wireproto/funcs_fieldname.go

76 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-07-09 23:40:20 -04:00
package wireproto
// MarshalBinary renders a FieldName into a byte-packed format.
func (f *FieldName) MarshalBinary() (data []byte, err error) {
if f == nil {
data = []byte{}
return
}
data = []byte(*f)
return
}
// MarshalText renders a FieldName into plaintext.
func (f *FieldName) MarshalText() (data []byte, err error) {
if f == nil {
data = []byte{}
return
}
data = []byte(*f)
return
}
// UnmarshalBinary populates a FieldName from packed bytes.
func (f *FieldName) UnmarshalBinary(data []byte) (err error) {
if data == nil || len(data) == 0 {
return
}
*f = FieldName(data)
return
}
// UnmarshalText populates a FieldName from plaintext.
func (f *FieldName) UnmarshalText(data []byte) (err error) {
if data == nil || len(data) == 0 {
return
}
*f = FieldName(data)
return
}
// Size returns the FieldName's calculated size (in bytes).
func (f *FieldName) Size() (size int) {
if f == nil {
return
}
size = len(*f)
return
}
// String returns a string representation of a FieldName.
func (f *FieldName) String() (s string) {
if f == nil {
return
}
s = string([]byte(*f))
return
}