DEV Community

Cover image for Rust-Time Communication.
bolubee101 for Rust Nigeria

Posted on

Rust-Time Communication.

The final year in school is a trying time for a lot of people, and I was not an exception. I was working on my final year project, a chatting application for my school, the University of Lagos. My goal was to include text chat, video calls, and voice calls into the application which I intended to write in Golang. I did that, and it worked. It was done…or so I thought. During the testing phase, I had a couple of classmates, about 20 or so, connect to my server to test my application out. It lagged and was pretty much unusable. I had to look for an alternative. Then suddenly, the ASUU strike hit, and there was time to rewrite my project 10-50 times, as many times as I wanted. ASUU, Academic Staff Union of Universities, is the body to whom all university lecturers report, and its members went on an indefinite strike. The reason? The government had some unpaid dues or something. Anyway, a strike meant no classes, no classes meant no school, no school meant more time…plenty of time.

I had known about Rust before, and I had done a bit of research myself. A couple of things stood out to me. Its low-level access, the absence of a garbage collector, and its famous speed. It ticked all the boxes I wanted. Also, implementing my project in Rust potentially meant lower costs. Rust is really low level, so it makes the most of the resources available. That meant that I didn’t have to get a powerful server to cater to my project’s needs. So I started learning Rust.

With the strike in session, I had a lot of time on my hands to learn what I needed to learn, and things went on smoothly till I hit a brick wall. I couldn’t find a Web RTC implementation in Rust. Web RTC is a framework that allows browsers and web-based applications to communicate in real-time. It is important to know that while Rust has made a lot of waves in recent times, it is still relatively new compared to other languages and development technology. There were still things that had not fully been abstracted to the level where regular developers could easily access the functionalities without having a deep understanding of how they worked. Web RTC was one of them. Now that I think of it, I found one, but it was basically just C embedded in Rust. While that sort of worked, It wasn’t what I wanted. I searched around a bit more, then I found someone, Rainliu working on a Web RTC implementation in Rust. It was in its early stages though, in fact, all that had been done was a collated list of frameworks that would allow Web RTC to work in Rust. I decided to help out, or at least try to help. There I was, a few weeks into learning Rust, and I wanted to help build a library.

The idea was to port Pion, the web RTC library in Go to Rust, and I played a major role in the early days of the project. I was involved in the RTP library, SRTP, and the Multicast DNS. I put in a lot of time, a commodity the strike ensured I had a lot of, and we made a lot of progress. In fact, a lot of people rallied behind the project making it worthy of the title Open source. It currently has almost 2000 stars on Github.

At my current workplace, Ockam, we work with many languages and stacks. I work in DevOps but Rust plays a major role in it. Amazingly enough, I learned about the job as a result of the massive publicity for the first event hosted by Rust Nigeria in 2020. Ockam put out a recruitment post under one of the publicity tweets. After checking out their website, I was interested so I applied. Ockam deals majorly with IT security, so a lot of their products deal with security issues. In preparation for my interview, I decided to use one of their Rust implementations to secure an application I had made before, particularly my MDNS implementation. There is a known security flaw in MDNS in which in basic terms, identity could be impersonated so I used an Ockam toolkit to secure it. I presented a demo of this for my interview and I got the job.

I cannot imagine ever leaving Rust and I don’t believe anyone who starts with Rust will ever want to go back. The idea that you have the compiler on your side is such an assurance. There are some mistakes that I’d make and the compiler would calm you down, then school you. There are mistakes impossible to take into production if you follow the rules and regulations of the compiler. For example, unless you use unsafe code, memory corruption is not something you’d worry about in production.

My experience with Rust since 2020 has been invaluable. With COVID and the rise in the need for video and voice communication services, the drive to get my project running was at an all-time high. Rust made it easy for me to keep working on what I wanted to, and this led me to open source, and with open source came experience and connections.

This story is based on Micheal Uti's journey with Rust.

Top comments (0)