encode
fun encode(type: UtMetadata.Type, piece: Int, totalSize: Long = 0, pieceData: ByteArray = ByteArray(0), includeTotalSize: Boolean = (type == Type.DATA)): ByteArray
General encoder. Builds the {msg_type, piece [, total_size]} dict and, for Type.DATA, appends pieceData after it.
total_size is emitted when includeTotalSize is true (always forced on for Type.DATA, to match libtorrent and BEP-9). pieceData is appended only for Type.DATA; it is ignored for request/reject.