]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add bencode.Bytes
authorMatt Joiner <anacrolix@gmail.com>
Fri, 26 Aug 2016 04:51:09 +0000 (14:51 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 26 Aug 2016 04:51:09 +0000 (14:51 +1000)
bencode/bytes.go [new file with mode: 0644]

diff --git a/bencode/bytes.go b/bencode/bytes.go
new file mode 100644 (file)
index 0000000..483feb7
--- /dev/null
@@ -0,0 +1,17 @@
+package bencode
+
+type Bytes []byte
+
+var (
+       _ Unmarshaler = &Bytes{}
+       _ Marshaler   = &Bytes{}
+)
+
+func (me *Bytes) UnmarshalBencode(b []byte) error {
+       *me = append([]byte(nil), b...)
+       return nil
+}
+
+func (me *Bytes) MarshalBencode() ([]byte, error) {
+       return *me, nil
+}