Skip to content

miniproto.connection.framing.NativeFrameCodec

miniproto.connection.framing.NativeFrameCodec

Section titled “miniproto.connection.framing.NativeFrameCodec”
NativeFrameCodec(mode: TransportMode | str, *, max_payload_size: int, server_side: bool = False) -> None

Typed adapter around the bundled Rust frame pump.

Create a typed adapter around the installed native codec.

Parameters:

  • mode (TransportMode | str) – MTProto TCP framing mode passed to the native implementation.
  • max_payload_size (int) – Maximum decoded MTProto payload size in bytes.
  • server_side (bool) – Interpret peer quick-ACK request flags as server-side input.

Raises:

  • ValueError – If mode or max_payload_size violates the same framing contract enforced by the pure-Python codec.
  • RuntimeError – If the native capability is unavailable or disappears between capability detection and codec construction.