From cbd414853f08f37130abb30b7b431112c3531640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Jul 2015 20:28:17 +0200 Subject: [PATCH] Move librespot into lib.rs and let main.rs be the test binary --- Cargo.toml | 8 ++++++++ src/audio_file.rs | 2 +- src/lib.rs | 37 +++++++++++++++++++++++++++++++++++++ src/main.rs | 34 ++++++++++------------------------ 4 files changed, 56 insertions(+), 25 deletions(-) create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index fd8012e0..186139bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,14 @@ version = "0.1.0" authors = ["Paul LiƩtar "] build = "build.rs" +[lib] +name = "librespot" +path = "src/lib.rs" + +[[bin]] +name = "main" +path = "src/main.rs" + [dependencies.librespot-protocol] path = "protocol" diff --git a/src/audio_file.rs b/src/audio_file.rs index b84f5f84..2e1f0ee0 100644 --- a/src/audio_file.rs +++ b/src/audio_file.rs @@ -20,7 +20,7 @@ pub enum AudioFile<'s> { Loading(AudioFileLoading<'s>) } -struct AudioFileLoading<'s> { +pub struct AudioFileLoading<'s> { read_file: TempFile, position: u64, diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..f0cef3f9 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,37 @@ +#![crate_name = "librespot"] + +#![feature(plugin,scoped,zero_one,iter_arith,slice_position_elem,slice_bytes,bitset,arc_weak,append,future)] +#![allow(deprecated)] +#![allow(unused_imports,dead_code)] + +#![plugin(protobuf_macros)] +#[macro_use] extern crate lazy_static; + + +extern crate byteorder; +extern crate crypto; +extern crate gmp; +extern crate num; +extern crate portaudio; +extern crate protobuf; +extern crate shannon; +extern crate rand; +extern crate readall; +extern crate vorbis; +extern crate time; +extern crate tempfile; + +extern crate librespot_protocol; + +#[macro_use] pub mod util; +pub mod audio_decrypt; +pub mod audio_file; +pub mod audio_key; +pub mod connection; +pub mod keys; +pub mod mercury; +pub mod metadata; +pub mod player; +pub mod session; +pub mod stream; +pub mod subsystem; diff --git a/src/main.rs b/src/main.rs index e86c5004..889f5dff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -#![crate_name = "librespot"] - -#![feature(plugin,scoped,zero_one,iter_arith,slice_position_elem,slice_bytes,bitset,arc_weak,append,future)] +#![feature(plugin,scoped)] #![allow(deprecated)] //#![allow(unused_imports,dead_code)] @@ -18,23 +16,9 @@ extern crate shannon; extern crate rand; extern crate readall; extern crate vorbis; -extern crate time; -extern crate tempfile; extern crate librespot_protocol; - -#[macro_use] mod util; -mod audio_decrypt; -mod audio_file; -mod audio_key; -mod connection; -mod keys; -mod mercury; -mod metadata; -mod player; -mod session; -mod stream; -mod subsystem; +#[macro_use] extern crate librespot; use std::clone::Clone; use std::fs::File; @@ -44,12 +28,14 @@ use protobuf::core::Message; use std::thread; use std::path::PathBuf; -use metadata::{AlbumRef, ArtistRef, TrackRef}; -use session::{Config, Session}; -use util::SpotifyId; -use util::version::version_string; -use player::{Player, PlayerCommand}; -use mercury::{MercuryRequest, MercuryMethod}; +use librespot::util; +use librespot::metadata::{AlbumRef, ArtistRef, TrackRef}; +use librespot::session::{Config, Session}; +use librespot::util::SpotifyId; +use librespot::util::version::version_string; +use librespot::player::{Player, PlayerCommand}; +use librespot::mercury::{MercuryRequest, MercuryMethod}; + use librespot_protocol as protocol; use librespot_protocol::spirc::PlayStatus;