]> Sergey Matveev's repositories - btrtrc.git/blob - bencode/bytes.go
Fix panic unmarshalling bencode dict into unsupported type
[btrtrc.git] / bencode / bytes.go
1 package bencode
2
3 type Bytes []byte
4
5 var (
6         _ Unmarshaler = &Bytes{}
7         _ Marshaler   = &Bytes{}
8         _ Marshaler   = Bytes{}
9 )
10
11 func (me *Bytes) UnmarshalBencode(b []byte) error {
12         *me = append([]byte(nil), b...)
13         return nil
14 }
15
16 func (me Bytes) MarshalBencode() ([]byte, error) {
17         return me, nil
18 }