Skip to Content
Rust Programming By Example
book

Rust Programming By Example

by Guillaume Gomez, Antoni Boucher
January 2018
Beginner to intermediate
454 pages
10h 8m
English
Packt Publishing
Content preview from Rust Programming By Example

Playing music

First, add the mp3 module:

mod mp3;

Copy the src/mp3.rs file from the previous chapter.

We also need the following dependencies:

[dependencies]
crossbeam = "^0.3.0"
futures = "^0.1.16"
pulse-simple = "^1.0.0"
simplemad = "^0.8.1"

And add these statements to the main module:

extern crate crossbeam;
extern crate futures;
extern crate pulse_simple;
extern crate simplemad;

We'll now add a player module:

mod player;

This new module will start with a bunch of import statements:

use std::cell::Cell;
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::Duration;

use crossbeam::sync::SegQueue;
use futures::{AsyncSink, Sink};
use futures::sync::mpsc::UnboundedSender; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rust Programming Cookbook

Rust Programming Cookbook

Claus Matzinger
Rust Web Programming

Rust Web Programming

Maxwell Flitton

Publisher Resources

ISBN: 9781788390637Supplemental Content