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

Playlist

We're now ready to create a new widget: the playlist. We'll need the following new dependencies:

[dependencies]
id3 = "^0.2.0"
m3u = "^1.0.0"

Add their corresponding extern crate statements:

extern crate id3;
extern crate m3u;

Let's create a new module for our playlist:

mod playlist;

In the src/playlist.rs file, we start by creating our model:

use gtk::ListStore;

pub struct Model {
    current_song: Option<String>,
    model: ListStore,
    relm: Relm<Playlist>,
}

The Relm type comes from the relm crate:

use relm::Relm;

It is useful to send messages to a widget. We'll learn more about that in the section about widget communication. Let's add the model initialization function:

use gdk_pixbuf::Pixbuf;
use gtk::{StaticType, Type};

#[widget]
impl ...
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