You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
488 B
24 lines
488 B
import six
|
|
from websocket import ABNF
|
|
|
|
from disco.gateway.encoding.base import BaseEncoder
|
|
|
|
if six.PY3:
|
|
from earl import unpack, pack
|
|
else:
|
|
from erlpack import unpack, pack
|
|
|
|
|
|
class ETFEncoder(BaseEncoder):
|
|
TYPE = 'etf'
|
|
OPCODE = ABNF.OPCODE_BINARY
|
|
|
|
@staticmethod
|
|
def encode(obj):
|
|
return pack(obj)
|
|
|
|
@staticmethod
|
|
def decode(obj):
|
|
if six.PY3:
|
|
return unpack(obj, encoding='utf-8', encode_binary_ext=True)
|
|
return unpack(obj)
|
|
|