Announcing the PubNub Rust SDK

4 min read Oliver Carson on Aug 30, 2023
PN-Rust-SDK-Blog-Image (1).png

Hello, fellow Rustaceans! We are excited to announce the PubNub Rust SDK, the easiest way for developers to leverage PubNub’s real-time features in any kind of Rust applications, such as chat, live audience engagement, multi-user collaboration, IoT device control, gaming, and more. This isn’t just about a new language; it’s a leap toward an efficient, cost-effective, robust, and secure real-time experience.

What is Rust?

Rust is an open-source programming language focusing on memory safety and preventing segfaults with its strict compiler. Based on the design philosophy of C and C++, its concurrency model, zero-cost abstractions, and non-reliance on garbage collection at runtime make it an excellent choice for real-time applications, as it offers the control of a low-level language with the helpful abstractions of a high-level one. It’s even been found that applications developed in Rust that run on ARM systems improve efficiency by providing better performance at a lower price

In fact, according to the 2022 Developer Survey by Stack Overflow, Rust is the community’s most loved language for the seventh year in a row, “with 87% of developers saying they want to continue using it” and “ties with Python as the most wanted technology with TypeScript running a close second.”

If you’re curious about Rust but have never tried it before, worry not - Rust’s syntax and modules will make the transition from other languages, such as Python, Java, or JavaScript, much easier than C/C++. It supports WebAssembly, making frontend tasks smoother, and the ‘cargo’ package manager ensures easy management of dependencies. To delve deeper into Rust, check out their official documentation. It offers comprehensive installation guidelines, detailed documentation, and practical tutorials to get you started.

Rust Improves Performance and Lowers Costs at PubNub

Aside from its popularity, Rust has provided the PubNub platform with significant performance boosts, improved safety, and reduced operational costs for our architecture. We never want to become stagnant and decided to re-architect some of our services and applications with Rust to develop high-performing and reliable APIs that can handle the demands of modern real-time applications. We saw a workflow improvement of up to 50% and significant operational cost savings meaning we can now deliver real-time updates with even lower latencies and costs. This makes perfect sense with the PubNub platform, as we provide low-latency communications for hundreds of millions of messages monthly. We’ve even created a Rust CLI to ensure a smooth transition between old and new systems with these new changes!

You can learn more in-depth about how Rust helps us deliver best-in-class APIs.

Empowering Rust Developers with PubNub

Based on our love for Rust and how it helped us improve our platform, we wanted to make it easier for developers in our community to use PubNub features to power their applications. The PubNub Rust SDK isn't just another tool—it’s a game-changer. With its async operations, it's optimized for real-time applications, be it chat, IoT device control, geolocation solutions, gaming, blockchain & Web3, data streaming, or enterprise software. 

While Rust developers in the past were able to make use of the PubNub platform by using our REST API, Rustaceans can now use PubNub Rust SDK to power the following functionality in their apps directly or in conjunction with other PubNub services:

  • Publish/Subscribe: Our Publish and Subscribe APIs make it easy to deliver high volume, in-app messages 1:1 or to an unlimited number of Channels, anywhere around the globe, in less than 100ms.

  • Presence: Track and alert on online/offline events for users and devices, as well as track accurate occupancy counts across channels with millions of connected devices.

  • Access Manager: Fine-grained access control that offers a cryptographic, token-based permission administrator that allows you to regulate clients' access to PubNub resources.

  • Functions: Run your code within our network or leverage existing integrations to transform, re-route, augment, filter, aggregate messages, run code triggered by user presence events, and more, all computed at the edge.

  • Events & Actions: Enables business users to filter events to manage event listeners and associate actions with no code.

  • PubNub Insights: Aggregated metrics and usable analytics built from your PubNub data & utilization.

Getting Started with the PubNub Rust SDK

To begin implementing these features in your own Rust application, you’ll need to import and add PubNub to your Rust project in the Cargo.toml file:

Then, you’ll need to configure PubNub to be able to use all of the features we described earlier. Here is a template you can use:

Please be sure to go to our official docs for more details. You’ll need to replace the my_publish_key and my_subscribe_key parameters with your publish keys and subscribe keys, respectively, from your free PubNub account, which ensures proper authentication for your application to connect to the PubNub network.

Our SDK integrates easily with major providers like AWS, Microsoft Azure, GCP, IBM Cloud, Oracle, and Kubernetes, as well as frameworks such as React. Plus, it's open-source on! Developers can freely tweak, optimize, and debug using familiar tools. And remember - the PubNub network is platform and device agnostic, so you never have to worry if implementing Rust into your applications will hurt your current ecosystem.

What's Next

PubNub Rust is a powerful language that continues to excite developers worldwide with its capabilities by improving their systems and applications - including us! We wanted to create this SDK so other developers can easily and effectively integrate PubNub into their Rust applications.

To get started with the PubNub Rust SDK, check out the following resources:

We want to reiterate our commitment to improving the experience of Rustaceans using the PubNub Rust SDK. We encourage you to download and try out the new SDK for your real-time projects and provide us with your valuable feedback or questions anytime at and fork the SDK repository to implement your features to help us further refine and enhance the SDK. Be on the lookout for upcoming guides and tutorials for implementing PubNub into Rust applications. Happy coding, Rustaceans!