pymprpc.mixins package

Submodules

pymprpc.mixins.encoder_decoder_mixin module

定义mprpc客户端和服务器中通用的编码解码混入类.

  • File: encoder_decoder_mixin.py

  • Version: 0.5

  • Author: hsz

  • Email: hsz1273327@gmail.com

  • Copyright: 2018-02-08 hsz

  • License: MIT

  • History

    • 2018-01-23 created by hsz
    • 2018-01-23 version-0.5 by hsz
class pymprpc.mixins.encoder_decoder_mixin.EncoderDecoderMixin[source]

Bases: object

编码解码混入类,用于从读入的字节串中解码出数据,或者将数据编码为字节串.

需要被混入的类中有:

SEPARATOR

bytes

  • 用于标明读取字节终止符
VERSION

str

  • 标识协议版本
decoder(response: bytes)[source]

编码请求为bytes.

检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.

Parameters:response (bytes) –
  • 响应的字节串编码
Returns:
  • python字典形式的响应
Return type:(Dict[str, Any])
encoder(query: Dict[str, Any])[source]

编码请求为bytes.

检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.

Parameters:query (Dict[str, Any]) –
  • python字典形式的请求数据
Returns:
  • 请求的字节串
Return type:(bytes)

Module contents