neroplatinum.blogg.se

Async rust book
Async rust book




async rust book
  1. ASYNC RUST BOOK HOW TO
  2. ASYNC RUST BOOK SOFTWARE
  3. ASYNC RUST BOOK CODE
async rust book

ASYNC RUST BOOK CODE

  • Specifying whether a code snippet only compiles to no_std or can use the std library.
  • Other attribute like macros are also common throughout Substrate's codebase for: When you're getting started with Substrate, it isn't so important to know exactly how they work, but rather to know that they exist that they empower you to write correct runtime code.ĭerive attributes are useful for custom runtime types that need to satisfy certain traits, for instance, to have types be decodable by a node during runtime execution. This is especially useful to help developers write code that can integrate with the complexity of a Substrate runtime.įor example, the # macro is required in all FRAME pallets to help you correctly implement certain required attributes-such as storage items or externally callable functions-and make it compatible with the build process in construct_runtime.ĭeveloping Substrate runtimes involves heavy use of Rust's attribute macros, which come in two flavors: derive attributes and custom attributes. Rust macros are a powerful tool to help ensure certain requirements are met (without re-writing code) such as the logic to be formatted in a specific way, specific checks are made, or some logic consists of specific data structures. These macros allow you to focus on writing idiomatic Rust and application-specific logic instead of the common code required to interact with a runtime.

    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.

    async rust book

    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

    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:






    Async rust book