"Write the given thing to the output stream. “Thing” means here a
- string, map, sequence or integer."
+ string, map, sequence or integer. Alternatively an ByteArray may
+ be provided whose contents are written as a bytestring."
+ (instance? (RT/classForName "[B") thing) :bytes
;; Check for various sequency things. Yes. This is tedious. But as long
-;; The following methods should be pretty straight-forward. For strings
-;; we simply write the string as a netstring without trailing comma.
+;; The following methods should be pretty straight-forward.
+;; The easiest case is of course when we already have a byte array.
+;; We can simply pass it on to the underlying machinery.
+(defmethod write-bencode :bytes
+ (write-netstring* output bytes))
+;; For strings we simply write the string as a netstring without
+;; trailing comma after encoding the string as UTF-8 bytes.
(defmethod write-bencode :string