Rust Programming By Example

Discover the world of Rust programming through real-world examples
Preview in Mapt

Rust Programming By Example

Guillaume Gomez, Antoni Boucher

4 customer reviews
Discover the world of Rust programming through real-world examples
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $35.99
Save 72%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$44.99
$29.99 p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Rust Programming By Example Book Cover
Rust Programming By Example
$ 35.99
$ 10.00
Network Programming with Rust Book Cover
Network Programming with Rust
$ 35.99
$ 10.00
Buy 2 for $20.00
Save $51.98
Add to Cart

Book Details

ISBN 139781788390637
Paperback454 pages

Book Description

Rust is an open source, safe, concurrent, practical language created by Mozilla. It runs blazingly fast, prevents segfaults, and guarantees safety. This book gets you started with essential software development by guiding you through the different aspects of Rust programming. With this approach, you can bridge the gap between learning and implementing immediately.

Beginning with an introduction to Rust, you’ll learn the basic aspects such as its syntax, data types, functions, generics, control flows, and more. After this, you’ll jump straight into building your first project, a Tetris game. Next you’ll build a graphical music player and work with fast, reliable networking software using Tokio, the scalable and productive asynchronous IO Rust library.

Over the course of this book, you’ll explore various features of Rust Programming including its SDL features, event loop, File I/O, and the famous GTK+ widget toolkit. Through these projects, you’ll see how well Rust performs in terms of concurrency—including parallelism, reliability, improved performance, generics, macros, and thread safety. We’ll also cover some asynchronous and reactive programming aspects of Rust.

By the end of the book, you’ll be comfortable building various real-world applications in Rust.

Table of Contents

Chapter 1: Basics of Rust
Getting to know Rust
Documentation and reference
Main function
Built-in data types
Control flow
Creating functions
Creating structures
References
Methods
Tuples
Enumerations
Pattern matching
Traits
Generics
Arrays
Macros
Summary
Chapter 2: Starting with SDL
Understanding Rust crates
Installing SDL2
Setting up your Rust project
Rust's modules
Tetris
Creating a window
Drawing
Handling files
Summary
Chapter 3: Events and Basic Game Mechanisms
Writing Tetris
Summary
Chapter 4: Adding All Game Mechanisms
Getting started with game mechanisms
Summary
Chapter 5: Creating a Music Player
Installing the prerequisite
Creating your first window
Creating a toolbar
Improving the organization of the application
Adding tool button events
Containers
Adding a playlist
Opening MP3 files
Summary
Chapter 6: Implementing the Engine of the Music Player
Installing the dependencies
Decoding MP3 files
Playing music
Pausing and resuming the song
Showing the progression of the song
Improving CPU usage
Showing the song's current time
Loading and saving the playlist
Using gstreamer for playback
Summary
Chapter 7: Music Player in a More Rusty Way with Relm
Reasons to use relm instead of gtk-rs directly
Creating a window with relm
Widget
Adding child widgets
Playlist
Adding a relm widget
Communicating between widgets
Playing music
Computing the song duration
Using relm on stable Rust
Relm widgets data binding
Summary
Chapter 8: Understanding FTP
File transfer protocol
Summary
Chapter 9: Implementing an Asynchronous FTP Server
Advantages of asynchronous IO
Disadvantages of asynchronous IO
Creating the new project
Using Tokio
Using futures
Handling errors
Starting the Tokio event loop
Starting the server
Handling commands
Managing the current working directory
Setting the transfer type
Entering passive mode
Quitting
Creating directories
Removing directories
Summary
Chapter 10: Implementing Asynchronous File Transfer
Listing files
Downloading a file
Uploading files
Going further!
Unit tests
Integration tests
Documentation
Documentation tests
Fuzzing tests
Summary
Chapter 11: Rust Best Practices
Rust best practices
Summary

What You Will Learn

  • Compile and run the Rust projects using the Cargo-Rust Package manager
  • Use Rust-SDL features such as the event loop, windows, infinite loops, pattern matching, and more
  • Create a graphical interface using Gtk-rs and Rust-SDL
  • Incorporate concurrency mechanism and multi-threading along with thread safety and locks
  • Implement the FTP protocol using an Asynchronous I/O stack with the Tokio library

Authors

Table of Contents

Chapter 1: Basics of Rust
Getting to know Rust
Documentation and reference
Main function
Built-in data types
Control flow
Creating functions
Creating structures
References
Methods
Tuples
Enumerations
Pattern matching
Traits
Generics
Arrays
Macros
Summary
Chapter 2: Starting with SDL
Understanding Rust crates
Installing SDL2
Setting up your Rust project
Rust's modules
Tetris
Creating a window
Drawing
Handling files
Summary
Chapter 3: Events and Basic Game Mechanisms
Writing Tetris
Summary
Chapter 4: Adding All Game Mechanisms
Getting started with game mechanisms
Summary
Chapter 5: Creating a Music Player
Installing the prerequisite
Creating your first window
Creating a toolbar
Improving the organization of the application
Adding tool button events
Containers
Adding a playlist
Opening MP3 files
Summary
Chapter 6: Implementing the Engine of the Music Player
Installing the dependencies
Decoding MP3 files
Playing music
Pausing and resuming the song
Showing the progression of the song
Improving CPU usage
Showing the song's current time
Loading and saving the playlist
Using gstreamer for playback
Summary
Chapter 7: Music Player in a More Rusty Way with Relm
Reasons to use relm instead of gtk-rs directly
Creating a window with relm
Widget
Adding child widgets
Playlist
Adding a relm widget
Communicating between widgets
Playing music
Computing the song duration
Using relm on stable Rust
Relm widgets data binding
Summary
Chapter 8: Understanding FTP
File transfer protocol
Summary
Chapter 9: Implementing an Asynchronous FTP Server
Advantages of asynchronous IO
Disadvantages of asynchronous IO
Creating the new project
Using Tokio
Using futures
Handling errors
Starting the Tokio event loop
Starting the server
Handling commands
Managing the current working directory
Setting the transfer type
Entering passive mode
Quitting
Creating directories
Removing directories
Summary
Chapter 10: Implementing Asynchronous File Transfer
Listing files
Downloading a file
Uploading files
Going further!
Unit tests
Integration tests
Documentation
Documentation tests
Fuzzing tests
Summary
Chapter 11: Rust Best Practices
Rust best practices
Summary

Book Details

ISBN 139781788390637
Paperback454 pages
Read More
From 4 reviews

Read More Reviews

Recommended for You

Network Programming with Rust Book Cover
Network Programming with Rust
$ 35.99
$ 10.00
Mastering Linux Security and Hardening Book Cover
Mastering Linux Security and Hardening
$ 35.99
$ 10.00
Rust High Performance Book Cover
Rust High Performance
$ 35.99
$ 10.00
Learning Node.js Development Book Cover
Learning Node.js Development
$ 31.99
$ 10.00
RUST Design Patterns and Best Practices Book Cover
RUST Design Patterns and Best Practices
$ 0.00
C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition Book Cover
C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition
$ 31.99
$ 10.00