miniproto_native::transport::TransportCodec
Provenance
Section titled “Provenance”- Crate:
miniproto_native - Rust visibility:
restricted - Source:
rust/miniproto/src/transport.rs - Python exposure:
miniproto._native.TransportCodec(confirmed from adjacent PyO3 attributes)
cargo-docs-md rendering
Section titled “cargo-docs-md rendering”TransportCodec
Section titled “TransportCodec”struct TransportCodec { pump: FramePump,}Defined in rust/miniproto/src/transport.rs:123-126
Python-visible incremental TCP framing codec, exported as miniproto._native.TransportCodec.
Fields
Section titled “Fields”-
pump:FramePumpStateful native parser and encoder backing this Python object.
Implementations
Section titled “Implementations”-
fn new(mode: &str, max_payload_size: usize, server_side: bool) -> PyResult<Self>Creates
TransportCodec(mode, max_payload_size, server_side=False).modemust be a supported Python transport name andmax_payload_sizemust be positive;otherwise this constructor raises
ValueError.Arguments
Section titled “Arguments”-
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 ofbeing 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
ValueErrorfor oversized payloads, invalid abridged alignment, length overflow,or operating-system randomness failure in padded mode.
Arguments
Section titled “Arguments”-
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
0payload,1quick ACK, and2negative transport error. It preservesincomplete trailing bytes for the next call and raises Python errors for invalid framing.
Arguments
Section titled “Arguments”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.
Arguments
Section titled “Arguments”-
py: The acquired GIL token used to build Pythonbytesand integer events. -
data: Newly received TCP bytes to append to this codec’s buffered stream.
-
Trait Implementations
Section titled “Trait Implementations”impl DerefToPyAny for TransportCodec
Section titled “impl DerefToPyAny for TransportCodec”impl ExtractPyClassWithClone for TransportCodec
Section titled “impl ExtractPyClassWithClone for TransportCodec”impl IntoPyObject for TransportCodec
Section titled “impl IntoPyObject 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>
impl IntoPyObjectExt for TransportCodec
Section titled “impl IntoPyObjectExt for TransportCodec”impl PyClass for TransportCodec
Section titled “impl PyClass for TransportCodec”-
const NAME: &str -
type Frozen = False
impl PyClassImpl for TransportCodec
Section titled “impl PyClassImpl for TransportCodec”-
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
impl PyErrArguments for TransportCodec
Section titled “impl PyErrArguments for TransportCodec”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
impl PyTypeCheck for TransportCodec
Section titled “impl PyTypeCheck for TransportCodec”-
fn type_check(object: &Bound<'_, PyAny>) -> bool -
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
impl PyTypeInfo for TransportCodec
Section titled “impl PyTypeInfo for TransportCodec”-
const NAME: &str -
const MODULE: ::std::option::Option<&str> -
fn type_object_raw(py: ::pyo3::Python<'_>) -> *mut ::pyo3::ffi::PyTypeObject
impl Same for TransportCodec
Section titled “impl Same for TransportCodec”type Output = T