diff --git a/Cargo.lock b/Cargo.lock index 2c6f905..402d1fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,9 @@ dependencies = [ "params 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", "router 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "shell32-sys 0.1.1 (git+https://github.com/retep998/winapi-rs?branch=0.2)", "sqlite 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -163,6 +165,11 @@ name = "dtoa" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "dtoa" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "encoding" version = "0.2.33" @@ -395,6 +402,11 @@ name = "itoa" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "itoa" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "jpeg-decoder" version = "0.1.8" @@ -792,6 +804,11 @@ dependencies = [ "num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rand" version = "0.3.15" @@ -881,6 +898,30 @@ name = "serde" version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "serde" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde_derive" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive_internals" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "serde_json" version = "0.8.3" @@ -892,6 +933,17 @@ dependencies = [ "serde 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_json" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sha1" version = "0.2.0" @@ -963,6 +1015,24 @@ dependencies = [ "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempdir" version = "0.3.5" @@ -1050,6 +1120,11 @@ name = "unicode-normalization" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unsafe-any" version = "0.4.1" @@ -1152,6 +1227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum dbghelp-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" "checksum deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1614659040e711785ed8ea24219140654da1729f3ec8a47a9719d041112fe7bf" "checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d" +"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90" "checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" "checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" "checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" @@ -1178,6 +1254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum inflate 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7e0062d2dc2f17d2f13750d95316ae8a2ff909af0fda957084f5defd87c43bb" "checksum iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fb1b2d809f84bf347e472d5758762b5c804e0c622970235f156d82673e4d334" "checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1" +"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c" "checksum jpeg-decoder 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4be50b418a1fc5d198588d9a4f682ef808a55db4084dce39d09bb0562525bb8c" "checksum kernel32-sys 0.2.2 (git+https://github.com/retep998/winapi-rs?branch=0.2)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -1224,6 +1301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0" "checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b" "checksum png 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "06208e2ee243e3118a55dda9318f821f206d8563fb8d4df258767f8e62bb0997" +"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" "checksum rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b6a6e05e0e6b703e9f2ad266eb63f3712e693a17a2702b95a23de14ce8defa9" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" @@ -1237,7 +1315,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" "checksum sequence_trie 0.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d5b4eb0f7d1ff9b9666d8b8ff543f3705dd464025269a5b0e1988ffa60ca1be8" "checksum serde 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)" = "58a19c0871c298847e6b68318484685cd51fa5478c0c905095647540031356e5" +"checksum serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3b46a59dd63931010fdb1d88538513f3279090d88b5c22ef4fe8440cfffcc6e3" +"checksum serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c06b68790963518008b8ae0152d48be4bbbe77015d2c717f6282eea1824be9a" +"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1" "checksum serde_json 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1cb6b19e74d9f65b9d03343730b643d729a446b29376785cd65efdff4675e2fc" +"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b" "checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c" "checksum shell32-sys 0.1.1 (git+https://github.com/retep998/winapi-rs?branch=0.2)" = "" "checksum shell32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72f20b8f3c060374edb8046591ba28f62448c369ccbdc7b02075103fb3a9e38d" @@ -1246,6 +1328,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum sqlite3-src 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6d9d456ae741b07c60ede84b0fa85bafad8275b1bb95bb42a93805d7475313b" "checksum sqlite3-sys 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2265dcf97c325725456e70bdfbbffb034b2f214964c065cbdea4b35e8647e63e" "checksum staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b28e731e7fcc67ce6aa4b53359d6922e193979175fbe85d5558fc71e692e4523" +"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" @@ -1258,6 +1342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "13a5906ca2b98c799f4b1ab4557b76367ebd6ae5ef14930ec841c74aed5f3764" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unsafe-any 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b351086021ebc264aea3ab4f94d61d889d98e5e9ec2d985d993f50133537fd3a" "checksum url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7" "checksum urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5ddcf2d3a0beedb5cdf50cabc521ab76a994907877a1d91d996c251d42c70e2e" diff --git a/Cargo.toml b/Cargo.toml index 318e731..7ae9ab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,9 @@ oven = { git = "https://github.com/agersant/oven", branch = "remove_cookie_dep" params = "0.5.1" regex = "0.1" router = "0.4.0" -rustc-serialize = "0.3" +serde = "1.0.2" +serde_derive = "1.0.2" +serde_json = "1.0.2" sqlite = "0.23.0" staticfile = "0.3.0" toml = "0.2" diff --git a/src/api.rs b/src/api.rs index c3d77a0..61ed6d4 100644 --- a/src/api.rs +++ b/src/api.rs @@ -10,7 +10,7 @@ use iron::{AroundMiddleware, Handler, status}; use mount::Mount; use oven::prelude::*; use params; -use rustc_serialize::json; +use serde_json; use url::percent_encoding::percent_decode; use collection::*; @@ -18,10 +18,10 @@ use errors::*; use thumbnails::*; use utils::*; -const CURRENT_MAJOR_VERSION: i32 = 1; -const CURRENT_MINOR_VERSION: i32 = 3; +const CURRENT_MAJOR_VERSION: i32 = 2; +const CURRENT_MINOR_VERSION: i32 = 0; -#[derive(RustcEncodable)] +#[derive(Serialize)] struct Version { major: i32, minor: i32, @@ -162,7 +162,7 @@ impl Handler for AuthHandler { fn version(_: &mut Request) -> IronResult { let current_version = Version::new(CURRENT_MAJOR_VERSION, CURRENT_MINOR_VERSION); - match json::encode(¤t_version) { + match serde_json::to_string(¤t_version) { Ok(result_json) => Ok(Response::with((status::Ok, result_json))), Err(e) => Err(IronError::new(e, status::InternalServerError)), } @@ -195,7 +195,7 @@ fn browse(request: &mut Request, collection: &Collection) -> IronResult j, Err(e) => return Err(IronError::new(e, status::InternalServerError)), @@ -212,7 +212,7 @@ fn flatten(request: &mut Request, collection: &Collection) -> IronResult j, Err(e) => return Err(IronError::new(e, status::InternalServerError)), @@ -223,7 +223,7 @@ fn flatten(request: &mut Request, collection: &Collection) -> IronResult IronResult { let random_result = collection.get_random_albums(20)?; - let result_json = json::encode(&random_result); + let result_json = serde_json::to_string(&random_result); let result_json = match result_json { Ok(j) => j, Err(e) => return Err(IronError::new(e, status::InternalServerError)), @@ -233,7 +233,7 @@ fn random(_: &mut Request, collection: &Collection) -> IronResult { fn recent(_: &mut Request, collection: &Collection) -> IronResult { let recent_result = collection.get_recent_albums(20)?; - let result_json = json::encode(&recent_result); + let result_json = serde_json::to_string(&recent_result); let result_json = match result_json { Ok(j) => j, Err(e) => return Err(IronError::new(e, status::InternalServerError)), diff --git a/src/index.rs b/src/index.rs index aab37ef..f43df0e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -38,7 +38,7 @@ pub struct Index { sleep_duration: u64, } -#[derive(Debug, RustcEncodable, PartialEq)] +#[derive(Debug, Serialize, PartialEq)] pub struct Song { path: String, track_number: Option, @@ -51,7 +51,7 @@ pub struct Song { artwork: Option, } -#[derive(Debug, RustcEncodable, PartialEq)] +#[derive(Debug, Serialize, PartialEq)] pub struct Directory { path: String, artist: Option, @@ -60,7 +60,7 @@ pub struct Directory { artwork: Option, } -#[derive(Debug, RustcEncodable, PartialEq)] +#[derive(Debug, Serialize, PartialEq)] pub enum CollectionFile { Directory(Directory), Song(Song), diff --git a/src/main.rs b/src/main.rs index a8c4b2c..8301d2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,22 +17,19 @@ extern crate ogg; extern crate oven; extern crate params; extern crate regex; -extern crate rustc_serialize; +extern crate serde; +#[macro_use] extern crate serde_derive; +extern crate serde_json; extern crate staticfile; extern crate sqlite; extern crate toml; extern crate url; -#[cfg(windows)] -extern crate uuid; -#[cfg(windows)] -extern crate winapi; -#[cfg(windows)] -extern crate kernel32; -#[cfg(windows)] -extern crate shell32; -#[cfg(windows)] -extern crate user32; +#[cfg(windows)] extern crate uuid; +#[cfg(windows)] extern crate winapi; +#[cfg(windows)] extern crate kernel32; +#[cfg(windows)] extern crate shell32; +#[cfg(windows)] extern crate user32; use errors::*; use getopts::Options;