


ASYNC RUST BOOK CODE
ASYNC RUST BOOK HOW TO
MacrosĪs you learn how to use and write FRAME pallets, you'll see there are many macros available as reusable code to abstract common tasks or enforce runtime-specific requirements. Substrate has a lot of its of own primitive types and associated traits that make it possible to work around the no_std requirement. This implies that you can't rely on some typical standard library types and functions and must only use no_std compatible crates for the majority of runtime code. When building a Substrate node, we use the wasm32-unknown-unknown compilation target which means that Substrate runtime engineers are constrained to writing runtimes that must compile to Wasm. Asynchronous Rust (for more advanced developers working with outer node (client) code).Īlthough general familiarity with Rust is essential before diving into Substrate-and there are many resources available for learning Rust, including the Rust Language Programming Book and Rust by Example-the remainder of this section highlights ways Substrate uses some of Rust's core features for developers getting started with runtime engineering.Basic Rust idioms, working with no_std and what macros are used and why (for runtime engineering).Generally, depending on their focus, developers should expect to know: While more complex features in Rust such as multithreading and asynchronous Rust are used in the outer node code, they aren't directly exposed to runtime engineers, making it easier for runtime engineers to focus on the business logic of their node. In the Architecture section, you will learn that Substrate is made of two distinct architectural components: the outer node and the runtime.

Rust is Wasm first: it has first class support for compiling to WebAssembly.Rust is memory safe: it has no garbage collector and it checks each and every variable you use and every memory address you reference to avoid any memory leaks.Rust is portable: it's designed to run on embedded devices with support for any type of operating system.Rust is fast: it's statically typed at compile time, making it possible for the compiler to optimize the code for speed and for developers to optimize for a specific compilation target.

ASYNC RUST BOOK SOFTWARE
Much of what makes Substrate a flexible and extensible framework for creating mission-critical software is owed to Rust.īeing the language of choice for Substrate, Rust is a highly performant programming language and a first choice for the following reasons:
