What you will learn in Refactoring to Rust
Chapter by chapter
Concepts explained in this book
- RustA statically typed systems programming language focused on memory safety, performance, and concurrency without a garbage collector.
- referenceA pointer is a value representing a memory address that can be used to access data indirectly.
- WebAssembly moduleA WebAssembly module is a compiled WebAssembly program containing code and associated definitions that can be instantiated by a host.
- PyO3PyO3 is a Rust library for creating Python extension modules and embedding or interacting with the Python interpreter.
- WasmEdgeThe WasmEdge SDK is a software development kit that provides APIs and functions for integrating WebAssembly modules with the WasmEdge runtime and host system.
- public visibilityA visibility modifier is Rust syntax that controls which modules or crates can access an item.
- global interpreter lockThe Python Global Interpreter Lock is a synchronization mechanism in CPython that restricts execution of Python bytecode to one thread at a time within a process.
- lifetime annotationA lifetime annotation is Rust syntax that names or relates the validity periods of references in types and function signatures.
- rust bindgenbindgen is a code-generation tool that creates language bindings from C and C++ declarations for use from Rust.
- no_mangleThe no_mangle attribute prevents the Rust compiler from applying symbol name mangling to an item.
- stringA string type is a type whose values represent text and whose representation determines how text storage and allocation are managed.
- error typeA custom error type is a programmer-defined type that represents the distinct failure conditions an operation can return.
- ownershipThe association in which a designated handle controls when a piece of memory is allocated and deallocated.
- borrowingRust's borrowing rules constrain the number, mutability, and validity of references to a value.
- lifetimeA lifetime is the period during which a value remains valid between allocation and being dropped.
- unsafe blockAn unsafe block is a Rust block that permits operations requiring an unsafe context, with the programmer responsible for upholding their safety conditions.
- postfix notationReverse Polish Notation is a postfix arithmetic expression notation in which operators follow their operands and evaluation proceeds without precedence rules.
- performancePerformance is the efficiency with which an application executes, commonly characterized by resource consumption and execution time.
- slicingA slice is a non-owning view of a contiguous region of elements represented by a pointer and a length.
- use declarationA use statement is Rust syntax that brings names or items into scope from a module or crate.
- refactoringA software-engineering process of restructuring existing code to improve qualities such as performance or maintainability without replacing the whole system.
- WebAssemblyWebAssembly is a portable bytecode instruction format and execution target for running compiled code in WebAssembly engines.
- WASIWASI is a standardized system interface that allows WebAssembly programs to access operating-system-like services in a portable way.
- memory allocationMemory allocation is the process of reserving and managing regions of computer memory for program data.
- moduleRust's module system organizes related items into modules and controls how code is named, accessed, and structured within crates.
- panicA panic is Rust's runtime mechanism for signaling an unrecoverable error or violated assumption.
- testA test function is a Rust function registered as an automated test by the test framework.
- dynamic libraryA dynamic module is a compiled extension loaded into a host program at runtime rather than statically embedded in it.
- handlerAn NGINX HTTP handler is a module function that receives an NGINX request structure and returns an integer request-processing status.
- payloadAn HTTP request body is the data payload carried in an HTTP request separately from its headers and request line.
- build scriptA Cargo build script is a Rust program run before package compilation to perform build-time configuration or generate source and other artifacts.
- interfaceAn interface is a language construct or component boundary that specifies functionality implementing components must provide.
- dereferencingA pointer dereference is an operation that accesses the value stored at the memory address represented by a pointer.
- DisplayThe Display trait is Rust's formatting trait for producing a user-facing textual representation of a value.
- enumAn enum is a type whose value is exactly one of a fixed set of named variants, with each variant optionally carrying associated data.
- reborrowingReborrowing is the conversion of a raw pointer into a Rust reference after the pointer's validity conditions have been established.
- include! macroThe Rust include! macro reads a file's text, parses it as Rust source code, and inserts the resulting code at the macro invocation.
- sandboxingA sandboxed environment is an isolated execution environment that restricts a program's access to resources outside explicitly permitted interfaces.
- structA struct is a Rust composite type that groups named fields into a single logical value and can have associated functionality.
- result typeResult is Rust's standard-library enum representing either success with an Ok value or failure with an Err value.
- memory safetyMemory safety is the property that software accesses memory only in valid ways, preventing errors such as use-after-free, buffer overflows, and invalid pointer dereferences.
- CStrCStr is Rust's standard-library borrowed string type for representing nul-terminated C strings without taking ownership of their storage.
- pymodule attributeThe PyO3 pymodule attribute macro defines a Rust function as the initializer for a Python extension module.
- application binary interfaceAn ABI is a binary-level calling convention and interface specification governing how separately compiled software components interact.
- C bindingsA Rust binding is interface metadata and declarations that expose the functions, types, and global variables of a foreign-language library to Rust code.
- unsafe RustUnsafe Rust is Rust code that permits operations the compiler cannot fully verify for memory safety and therefore places additional correctness responsibility on the programmer.
- Criterion.rsCriterion is a Rust benchmarking library that performs statistically driven performance measurements.
- raw pointerA raw pointer is a Rust pointer whose dereferencing and validity are not governed by the borrow checker and may require an unsafe context.
- benchmark harnessA benchmark harness is tooling that runs benchmark cases under comparable workloads and records measurements for comparison.
- concurrencyConcurrency is the structuring of multiple executions so that they make progress during overlapping periods without necessarily running simultaneously.
- calling conventionA C calling convention specifies how function arguments, return values, and calls are represented so compiled functions can interoperate with C.
- dynamic linkingDynamic linking is the process of resolving and loading library code separately from an executable, typically at program startup or runtime.
- name manglingName mangling is the compiler transformation of symbols into unique names that encode additional implementation information.
- null terminationA C string is a contiguous character sequence terminated by a null character.
- undefined behaviorUndefined behavior is program execution whose effects are not constrained by the language or platform specification.
- asynchronous programmingAsynchronous processing is execution in which work can proceed without waiting for a response from another operation.
- black_boxcriterion::black_box provides an opaque value boundary intended to prevent compiler optimization from eliminating benchmarked code.
- conditional compilationThe cfg attribute macro conditionally includes or excludes an annotated Rust item based on compile-time configuration.
- compilerA compiler is a program that translates source code into executable or lower-level code while performing analyses such as type checking.
- dequeA double-ended queue is a sequence data structure that supports insertion and removal at both its front and back.
- impl blockAn impl block is a Rust construct that defines methods and associated functions for a type.
- parsingparse is a Rust string operation that converts textual data into a value of an inferred or specified target type.
- componentA component is an isolated, reusable software unit that encapsulates a related portion of functionality, data, or user interface.
- stateState is data representing the current condition of a component or application.
- BencherBencher is the Criterion type that controls repeated execution of a benchmark iteration closure.
- cargo benchcargo bench is a Cargo command that builds and runs a package's benchmarks.
- confidence intervalA confidence interval is a statistical range that expresses uncertainty around an estimated quantity at a specified confidence level.
- criterion_group macroThe criterion_group macro defines a group of Criterion benchmark functions sharing a configuration.
- criterion_main macroThe criterion_main macro generates the main function for running registered Criterion benchmark groups.
- compiler optimizationAn optimizing compiler transforms source code while applying semantics-preserving transformations intended to improve runtime efficiency.
- py.runpy.run is a PyO3 operation that executes Python source code with supplied global and local namespaces.
- Python C APIThe Python C API is the C-level interface for embedding the Python interpreter and extending Python with native code.
- doc testA documentation test is an automated test generated by compiling and running executable code examples embedded in documentation.
- libc crateThe libc crate is a Rust library providing platform-specific bindings and type definitions for the C standard library and C-compatible primitives.
- threadA thread is an execution context within a process that includes a program counter, execution state, and access to process resources.
- mutable objectMutability is the property of a value or data structure that permits its contents to be changed after creation.
- namespaceA namespace is a named scope that contains identifiers and distinguishes them from identifiers in other scopes.
- garbage collectionGarbage collection is automatic reclamation of memory that is no longer reachable by a program.
- memory boundA bottleneck is a component or operation that limits the throughput or execution speed of a larger system.
- CargoCargo is Rust's package manager and build system for creating, compiling, running, testing, and distributing Rust projects.
- moveMove semantics is Rust's ownership-transfer behavior, under which a value becomes inaccessible through its original binding after transfer.
- callbackA callback function is a function supplied to another operation so that it can be invoked when a specified event or computation completes.
- extern "C"extern "C" is a Rust function annotation that gives a function the C ABI and makes it callable according to C conventions.
- function pointer typeA function pointer is a value that refers to a callable function and can be passed as an argument or stored for later invocation.
- ngx_http_read_client_request_bodyngx_http_read_client_request_body is an NGINX HTTP API function that asynchronously reads a client request body and invokes a completion callback.
- absolute pathAn absolute path is a Rust path resolved from a crate or other root namespace.
- relative pathA Rust relative path identifies an item from the current namespace or another namespace relative to the location where the path appears.
- serdeSerde is a Rust serialization and deserialization framework supporting multiple data formats through traits and derive macros.
- maturin developmaturin develop is a Maturin command that builds and installs a Rust-based Python extension module into a development Python environment.
- unit typeThe Rust unit type is a type with exactly one value, written as (), that represents the absence of a meaningful value.
- explicit memory managementManual memory management is a memory-management approach in which program developers explicitly control when memory is allocated and released.
- heapA heap is a dynamically managed memory region for data whose size or lifetime is not confined to a function call.
- memory deallocationDeallocation is the process of releasing memory so that it can be reused after the stored data is no longer needed.
- stackA stack is a last-in-first-out memory region or abstract data structure used for values such as function-call state and local variables.
- use-after-free errorUse after free is an error in which a program accesses memory after that memory has been deallocated.
- WebAssembly memoryWebAssembly memory is a resizable byte-addressable storage region associated with a WebAssembly module and accessible through the host interface.
- allowlistA whitelist is a selection rule that restricts generated bindings to explicitly matching declarations.
- to_string methodThe Rust to_string() method converts a value implementing ToString into an owned String.
- offsetoffset is a Rust pointer operation that produces a pointer displaced by a specified number of elements from a base pointer.
- ptr::copy_nonoverlappingstd::ptr::copy_nonoverlapping is a Rust standard-library function that copies a specified number of elements between non-overlapping memory regions.
- WebAssembly runtimeA WebAssembly runtime is software that loads, instantiates, and executes WebAssembly modules.
- assert_eqThe Rust assert_eq! macro compares two values for equality and panics when they differ.
- test attribute macroThe test attribute macro marks a Rust function for discovery and execution as an automated test.
- monkey patchingMonkey patching is the runtime replacement or modification of an object, function, or module implementation without changing its original source definition.
- maturinMaturin is a build and packaging tool for developing Python modules implemented in Rust.
- crate keywordThe crate keyword is a Rust path segment that refers to the root of the current crate.
- Python extension moduleA Python extension module is an importable Python module implemented partly or entirely in compiled native code.
- std::slice::from_raw_partsstd::slice::from_raw_parts is a Rust standard-library function that constructs a slice from a raw pointer and an element count.
- ngx_http_request_tngx_http_request_t is the NGINX C structure containing state and metadata for an HTTP request.
- import aliasAn import alias is an alternate local name assigned to an imported Rust item or path.
- serde_jsonserde_json is a Rust crate that converts between Serde's generic data model and JSON.
- blockingBlocking is execution behavior in which a process cannot proceed until a required resource or operation becomes available.
- PythonPython is a high-level general-purpose programming language commonly implemented with automatic memory management and garbage collection.
- Wasm virtual environmentA Wasm virtual environment is an isolated runtime context that supplies the host services required to execute a WebAssembly module.
- match statementA match expression is Rust's pattern-matching control-flow expression that selects and evaluates an arm based on a value's structure or variant.
- type hintsA type annotation is source-code syntax that explicitly declares the type associated with a value, variable, parameter, or return result.
- bit fieldA bitfield is a structure field occupying a specified number of individual bits rather than a whole storage unit.
- Content-Length headerThe Content-Length header is an HTTP header that declares the size in bytes of a response body.
- HTTP responseAn HTTP response is a structured message returned by an HTTP server containing the outcome and any result of processing an HTTP request.
- memory poolA memory pool is an allocator that obtains memory from a managed region and releases its allocations together when the pool is destroyed.
- ngx_buf_tngx_buf_t is an NGINX buffer structure that stores metadata and pointers describing a block of response data.
- ngx_chain_tngx_chain_t is an NGINX linked-chain structure that connects buffers for processing by HTTP output handlers.
- ngx_http_output_filterngx_http_output_filter is an NGINX API function that passes a request and buffer chain to HTTP output processing for transmission to a client.
- ngx_http_send_headerngx_http_send_header is an NGINX API function that sends HTTP response header data on a connection.
- parallelismParallelism is the execution of multiple computations simultaneously to perform work concurrently.
- assertionAn assertion is a program check that verifies a condition and reports failure when the condition is false.
- Rust testing systemThe Rust test framework is the component that discovers tests, executes them, captures output, and reports their results.
- test output captureTest output capture is the practice of storing a test's standard output and error streams and emitting them selectively in test reports.
- evaluation suiteA test suite is a collection of automated tests that collectively validate a software component.
- stack machineA stack machine is a computational model that evaluates instructions by operating on values stored in a last-in-first-out stack.
- type signatureA function signature specifies a function's parameter types, return type, and the semantic roles of those values.
- referenceAn immutable reference is a Rust non-owning reference that permits access to a value without modifying it through that reference.
- mutable referenceA mutable reference is a Rust non-owning reference that permits modification of the referenced value under Rust's aliasing rules.
- c_charc_char is a libc Rust type corresponding to the platform-specific C char primitive for foreign-function interfaces.
- mod keywordA mod statement is Rust syntax that declares a module and directs the compiler to its source definition.
- library crateA library crate is a Rust crate that provides code for inclusion by another executable rather than defining a directly executable program.
- pyfunction attribute macroThe pyfunction attribute macro is a PyO3 macro that generates a Python-compatible wrapper for a Rust function.
- PyModulePyModule is a PyO3 type representing a Python module exposed through the Python interpreter API.
- deserialize traitserde::Deserialize is the Serde trait for constructing Rust values from serialized external data, with a corresponding derive macro for generating implementations.
- idempotencyAn idempotent system produces the same externally relevant result when the same task is performed more than once.
- load balancingA load balancer is a system component that distributes incoming requests or tasks among multiple running service instances.
- horizontal scalingHorizontal scaling is increasing service capacity by running additional instances of a system.
- throughputThroughput is the amount of work a system completes per unit of time.
- vertical scalingVertical scaling is increasing the computational resources available to an existing machine or system instance.
- expectThe Rust expect operation extracts a contained Option or Result value and panics with a supplied message on absence or error.
- unwrapThe Rust unwrap operation extracts a contained Option or Result value and panics on absence or error.
- std::str::from_utf8std::str::from_utf8 is a Rust standard-library function that validates UTF-8 bytes and returns a string slice when they are valid.
- closureA closure is an anonymous function value that can be written inline and passed to or returned from other functions.
- map_err methodmap_err is a Result operation that transforms the error value of an Err result while leaving an Ok result unchanged.
- DebugThe Debug trait is a Rust formatting trait for producing developer-oriented representations of values.
- actionAn action is an event or command describing a state transition that a component should process.
- messageA Yew message is a value representing an action that can be processed by a component update operation.
- YewYew is a Rust framework for building web applications and web components that compile to WebAssembly.
- cargo featureA Cargo feature is a named configuration option that conditionally enables code paths, dependencies, or capabilities in a Rust crate.
- deserializationDeserialization is the conversion of a stored or transmitted representation into in-memory program values.
- JSONJSON is a text-based data interchange format representing structured values such as objects, arrays, strings, numbers, booleans, and null.
- type checkingType checking is the process of verifying that values and operations conform to the rules of a type system.
- lifetime graphA lifetime graph is a visualization that represents when values or variables are created, usable, moved, and destroyed.
- green threadA green thread is a runtime- or language-managed execution unit scheduled internally rather than directly by the operating system.
- POSIX Threads APIPOSIX threads are a standardized operating-system threading interface for creating and managing native threads.
- JSON objectA JSON object is an unordered collection of name-value pairs enclosed in braces and serialized in JSON syntax.
- contractAn API is a defined interface through which software components expose operations and exchange data.
- immutable stringAn immutable string is a string value whose character data cannot be modified after the value is created.
- capacityBuffer capacity is the number of elements a string buffer can hold before it requires additional allocation.
- reallocationReallocation is the process of obtaining a larger memory area and moving existing data into it when the current storage is insufficient.
- string bufferA string buffer is a memory region that stores the character data of a growable string together with its current length and capacity.
- workspaceA Cargo workspace is a collection of related Rust packages that share a lockfile and build output directory.
- derive macroA derive is a Rust compiler directive that generates implementations of selected traits for a type.
- incremental refactoringIncremental refactoring is a technique for restructuring software through a sequence of small, controlled changes rather than a single comprehensive rewrite.
- Copy traitThe Copy trait marks Rust types whose values can be duplicated implicitly without moving ownership from the original binding.
- scopeA region of source code within which a binding is accessible and whose end can trigger the dropping of owned values.
- path dependencyA path dependency is a package dependency resolved from a specified filesystem path instead of a package registry.
- type inferenceType inference is the compile-time deduction of expression or variable types from program context without requiring explicit annotations.
- NGINXNGINX is a high-performance web server and reverse proxy that can process HTTP requests and load application modules.
- module hierarchyA module hierarchy is a nested organization of modules that represents parent and child relationships in source code.
- foreign function interfaceA foreign function interface based on the C calling and binary interface that enables programs in different languages to call C-compatible functions and exchange compatible data.
- destructuring assignmentDestructuring is the extraction of component values from structured values such as enum variants through pattern matching.
- enum variantAn enum variant is one named alternative in an enum's finite set of possible values, optionally containing associated data.
- type safetyA strong static type system enforces compile-time type constraints and does not generally permit incompatible values to be used interchangeably.
- doc commentA doc comment is a Rust comment written with three slashes that is attached to an item and processed as API documentation.
- bundlingA bundler is a build tool that combines source modules and dependencies into one or more distributable assets.
- component-based designComponent-based development is a software design approach that structures systems as isolated, reusable components with related functionality or data.
- ReactReact is an open-source JavaScript library for building user interfaces from reusable components.
- ViteVite is a frontend build tool that provides development-server and asset-bundling tooling for modern JavaScript applications.
- multithreadingMultithreaded computation is the execution of computational work across multiple threads within a program.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
