MCPcopy Create free account
hub / github.com/chain/Core / MarshalText

Method MarshalText

protocol/bc/hash.go:46–51  ·  view source on GitHub ↗

MarshalText satisfies the TextMarshaler interface. It returns the bytes of h encoded in hex, for formats that can't hold arbitrary binary data. It never returns an error.

()

Source from the content-addressed store, hash-verified

44// for formats that can't hold arbitrary binary data.
45// It never returns an error.
46func (h Hash) MarshalText() ([]byte, error) {
47 b := h.Byte32()
48 v := make([]byte, 64)
49 hex.Encode(v, b[:])
50 return v, nil
51}
52
53// UnmarshalText satisfies the TextUnmarshaler interface.
54// It decodes hex data from b into h.

Callers 1

HexStringMethod · 0.95

Calls 2

Byte32Method · 0.95
EncodeMethod · 0.80

Tested by

no test coverage detected