// Package peer contains Protobuf and JSON serialization/deserialization methods for peer IDs.
package peer import ( ) // Interface assertions commented out to avoid introducing hard dependencies to protobuf. // var _ proto.Marshaler = (*ID)(nil) // var _ proto.Unmarshaler = (*ID)(nil) var _ json.Marshaler = (*ID)(nil) var _ json.Unmarshaler = (*ID)(nil) var _ encoding.BinaryMarshaler = (*ID)(nil) var _ encoding.BinaryUnmarshaler = (*ID)(nil) var _ encoding.TextMarshaler = (*ID)(nil) var _ encoding.TextUnmarshaler = (*ID)(nil) func ( ID) () ([]byte, error) { return []byte(), nil } // MarshalBinary returns the byte representation of the peer ID. func ( ID) () ([]byte, error) { return .Marshal() } func ( ID) ( []byte) ( int, error) { return copy(, []byte()), nil } func ( *ID) ( []byte) ( error) { *, = IDFromBytes() return } // UnmarshalBinary sets the ID from its binary representation. func ( *ID) ( []byte) error { return .Unmarshal() } func ( ID) () int { return len([]byte()) } func ( ID) () ([]byte, error) { return json.Marshal(.String()) } func ( *ID) ( []byte) ( error) { var string if = json.Unmarshal(, &); != nil { return } *, = Decode() return } // MarshalText returns the text encoding of the ID. func ( ID) () ([]byte, error) { return []byte(.String()), nil } // UnmarshalText restores the ID from its text encoding. func ( *ID) ( []byte) error { , := Decode(string()) if != nil { return } * = return nil }