In the Beta versions of Telegram for iOS and macOS, a new MTProtoRustEngine has appeared — a network engine implementation in Rust that is gradually replacing MTProtoKit.
MTProtoKit is Telegram's old network stack for Apple platforms. It has been developed for more than 10 years and is built with C, Objective-C, and C++. Public references to MtProtoKit for iOS and OS X date back to 2014.
Telegram is now gradually moving this part of its Apple clients to Rust. The new engine already has its own network sessions, request handling, buffers, data center communication, and a separate layer for interaction between Rust and Swift. The old code isn't going anywhere yet. Both engines are present in the client at the same time — MTProtoKit and Rust. Switching between them is handled by SwitchingNetworkEngine: if the new engine can't continue working, unfinished requests can be passed back to the old one.
There are also conditions under which the Rust engine isn't used, including Web Proxy, custom data center addresses, and certain app extensions. In these cases, Telegram continues using the old MTProtoKit.
Telegram has also added the mtproto_engine_rust_disabled configuration, which allows the server to forcibly disable the Rust engine. Together with the fallback to MTProtoKit, this allows Telegram to gradually move clients to the new stack and return to the old implementation when needed — without releasing a new client version.
@telelakel | #new_tgbeta
