miniproto.connection.framing.create_frame_codec
miniproto.connection.framing.create_frame_codec
Section titled “miniproto.connection.framing.create_frame_codec”create_frame_codec(mode: TransportMode | str, *, max_payload_size: int, server_side: bool = False) -> TransportFrameCodecCreate the fastest available codec for one MTProto TCP framing mode.
Parameters:
- mode (
TransportMode | str) – Requested TCP transport mode. - max_payload_size (
int) – Maximum permitted unframed MTProto payload size. - server_side (
bool) – Whether decoding models traffic received by a server.
Returns:
TransportFrameCodec– The native adapter when its extension is available; otherwise theTransportFrameCodec– behavior-equivalent pure-Python incremental codec.
Raises:
ValueError– If the fallback codec receives an unsupported mode or an invalid payload bound.RuntimeError– If the native extension is found but cannot initialize.