Skip to content

miniproto_native::transport::TransportCodec

  • Crate: miniproto_native
  • Rust visibility: restricted
  • Source: rust/miniproto/src/transport.rs
  • Python exposure: miniproto._native.TransportCodec (confirmed from adjacent PyO3 attributes)
struct TransportCodec {
pump: FramePump,
}

Defined in rust/miniproto/src/transport.rs:123-126

Python-visible incremental TCP framing codec, exported as miniproto._native.TransportCodec.

  • pump: FramePump

    Stateful native parser and encoder backing this Python object.

  • fn new(mode: &str, max_payload_size: usize, server_side: bool) -> PyResult<Self>

    Creates TransportCodec(mode, max_payload_size, server_side=False).

    mode must be a supported Python transport name and max_payload_size must be positive;

    otherwise this constructor raises ValueError.

    • mode: One of the supported Python TCP mode names.

    • max_payload_size: Positive upper bound for decoded application payload bytes.

    • server_side: Whether inbound quick-ACK request bits remain payload metadata instead of

      being interpreted as quick-ACK response frames.

  • fn encode_packet(&self, payload: &[u8], quick_ack: bool) -> PyResult<Vec<u8>>

    Encodes Python encode_packet(payload, quick_ack=False) into a single TCP frame.

    Returns ValueError for oversized payloads, invalid abridged alignment, length overflow,

    or operating-system randomness failure in padded mode.

    • payload: Complete MTProto payload to frame.

    • quick_ack: Whether to set the outbound quick-ACK request bit where the mode supports it.

  • fn feed_data(&mut self, data: &[u8]) -> PyResult<Vec<(u8, Vec<u8>, i64, bool)>>

    Feeds Python feed_data(data) and returns tagged native event tuples.

    Tuple kinds are 0 payload, 1 quick ACK, and 2 negative transport error. It preserves

    incomplete trailing bytes for the next call and raises Python errors for invalid framing.

    • data: Newly received TCP bytes to append to this codec’s buffered stream.
  • fn feed_transport_data(&mut self, py: Python<'_>, data: &[u8]) -> PyResult<Vec<Py<PyAny>>>

    Feeds compatibility feed_transport_data(data) and returns bytes or integer Python events.

    The GIL token is used only for object conversion after native parsing; malformed framing

    returns a Python exception.

    • py: The acquired GIL token used to build Python bytes and integer events.

    • data: Newly received TCP bytes to append to this codec’s buffered stream.

impl ExtractPyClassWithClone for TransportCodec
Section titled “impl ExtractPyClassWithClone for TransportCodec”
  • type Target = TransportCodec

  • type Output = Bound<'py, <TransportCodec as IntoPyObject>::Target>

  • type Error = PyErr

  • fn into_pyobject(self, py: ::pyo3::Python<'py>) -> ::std::result::Result<<Self as ::pyo3::conversion::IntoPyObject>::Output, <Self as ::pyo3::conversion::IntoPyObject>::Error>

  • const NAME: &str

  • type Frozen = False

  • const MODULE: ::std::option::Option<&str>

  • const IS_BASETYPE: bool

  • const IS_SUBCLASS: bool

  • const IS_MAPPING: bool

  • const IS_SEQUENCE: bool

  • const IS_IMMUTABLE_TYPE: bool

  • type Layout = <<TransportCodec as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout

  • type BaseType = PyAny

  • type ThreadChecker = NoopThreadChecker

  • type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

  • type Dict = PyClassDummySlot

  • type WeakRef = PyClassDummySlot

  • type BaseNativeType = PyAny

  • fn items_iter() -> ::pyo3::impl_::pyclass::PyClassItemsIter

  • const RAW_DOC: &'static ::std::ffi::CStr

  • const DOC: &'static ::std::ffi::CStr

  • fn lazy_type_object() -> &'static ::pyo3::impl_::pyclass::LazyTypeObject<Self>

impl PyClassNewTextSignature for TransportCodec
Section titled “impl PyClassNewTextSignature for TransportCodec”
  • const TEXT_SIGNATURE: &'static str
  • fn arguments(self, py: Python<'_>) -> Py<PyAny>
impl PyMethods for ::pyo3::impl_::pyclass::PyClassImplCollector<TransportCodec>
Section titled “impl PyMethods for ::pyo3::impl_::pyclass::PyClassImplCollector<TransportCodec>”
  • fn py_methods(self) -> &'static ::pyo3::impl_::pyclass::PyClassItems
  • fn type_check(object: &Bound<'_, PyAny>) -> bool

  • fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>

  • const NAME: &str

  • const MODULE: ::std::option::Option<&str>

  • fn type_object_raw(py: ::pyo3::Python<'_>) -> *mut ::pyo3::ffi::PyTypeObject

  • type Output = T