linerelectronics.blogg.se

Rust cross platform
Rust cross platform






  1. Rust cross platform how to#
  2. Rust cross platform install#

Elm is a typed, functional programming language. Now, in the spirit of type-safety and reliability, I opted in to using Elm for the frontend. The cool thing about using Rust is the ability to send and receive type-safe JSON something you can’t get out of the box with Electron. If you’ve ever used Electron, it’s extremely similar to using IPCs, which allow you to pass messages from the frontend to the backend and visa-versa. To actually render the GUI, I used a Rust library called webview, which renders HTML like a web browser and supports two-way bindings between Rust and JavaScript. I additionally made use of cargo-make, a build tool and task runner that I utilized to write initialization scripts. All rust crates can be found at crates.io it’s an excellent ecosystem and most libraries I used were well documented and supported.

Rust cross platform install#

To install a library all you need to do is add mylib = 1.0.0 under and run cargo check. A Rust project is configured through a Cargo.toml file. I found it fairly easy to work with and manage dependencies. Cargo can check your code, run and build your program, run tests, and much more. CargoĬargo is Rust’s package manager and is a powerful tool. Thankfully, the compiler will aid you in telling you where mutable and immutable borrows happen so you scope data properly sometimes it will tell you to issue annotations called lifetimes, which were needed sometimes when needing to explicitly describe how long some data needs to stay in memory. Additionally, I encountered some difficulty trying to mutate data structures in iterators due to the strict borrowing system I ended up either cloning data when needing to do filtering or other processes or creating a new vec! (like an array) to iteratively build the proper data structure.

Rust cross platform how to#

For example, if you want to clone a custom struct, you have define the requisite protocols so the compilier knows how to iterate through your data safely. I ran into some roadblocks when attempting to use functional iterators like map on my own custom structs due to trait implementation requirements. Additionally, the standard library is extremely robust and, more often than not, offers a utility that you are looking for. It offers structs, enums, generics, and many other excellent programming features you’ll find from your favorite languages. Though a bit foreign at first, Rust’s syntax ended up being a pleasure to work with. Your program will not compile if Rust deems it unsafe. Though it is not all-knowing as far as understanding the intention of what your program needs to do it knows what doesn’t work and will tell you why. Rust’s compiler is the perfectionist that you want at your side. But finally it was time to sit down and do my own thing. Reading through The Book, I went through some of the tutorial projects, so I was a tad familiar in writing Rust code. We all know the difference between reading about something and actually doing it. I, too, recommend anyone interested in Rust to read it it is excellently written, updated regularly, and covers many non-Rust specific programming practices that any developer can benefit from. Additionally, a co-worker recommended that I read the Rust book ( The Book), which is exactly what I did. Though diving right into the project with docs by my side was enticing, Rust was just a bit too terse and foreign to wing it. However, I ended up using Elm to build the frontend, which I’ll expand more on later. I used Rust to cache file references and serve data to a desktop webview, which renders HTML and JavaScript.

rust cross platform

Hence, I decided to make a video management app that keeps track of video files across multiple external devices. The reason I wanted to give Rust a shot was to get a deeper understanding of lower-level computing my prior experiences involved a couple problem sets in C from cs50 and making a print server in Electron (a way to make cross-platform apps using JavaScript).įor me, the best way to learn any new language or paradigm is to do a side project.

rust cross platform

If you want to write your good ol’ CRUD app, you can. If you want to talk to your GPU, you can. What I like to interpret this as is that Rust allows you to write low-level programs at a high level. Rust is a programming language, moreover a “multi-paradigm system programming language”. However today I’ll be talking about this rust.








Rust cross platform