From 520c140da848a6171950b1919ad40edec6c1d315 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Sun, 23 Apr 2017 15:29:48 +0100 Subject: [PATCH] Migrate to serde. Fixes #9 --- pcid/Cargo.toml | 5 +++-- pcid/src/config.rs | 4 ++-- pcid/src/main.rs | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pcid/Cargo.toml b/pcid/Cargo.toml index 9c0cf53..bc28166 100644 --- a/pcid/Cargo.toml +++ b/pcid/Cargo.toml @@ -4,5 +4,6 @@ version = "0.1.0" [dependencies] redox_syscall = "0.1" -rustc-serialize = "0.3" -toml = "0.2" +serde = "1.0" +serde_derive = "1.0" +toml = "0.4" diff --git a/pcid/src/config.rs b/pcid/src/config.rs index 3bc4dba..efe8894 100644 --- a/pcid/src/config.rs +++ b/pcid/src/config.rs @@ -1,9 +1,9 @@ -#[derive(Debug, Default, RustcDecodable)] +#[derive(Debug, Default, Deserialize)] pub struct Config { pub drivers: Vec } -#[derive(Debug, Default, RustcDecodable)] +#[derive(Debug, Default, Deserialize)] pub struct DriverConfig { pub name: Option, pub class: Option, diff --git a/pcid/src/main.rs b/pcid/src/main.rs index 469dec7..cee6b15 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -1,7 +1,8 @@ #![deny(warnings)] #![feature(asm)] -extern crate rustc_serialize; +extern crate serde; +#[macro_use] extern crate serde_derive; extern crate syscall; extern crate toml; @@ -25,7 +26,7 @@ fn main() { if let Ok(mut config_file) = File::open(&config_path) { let mut config_data = String::new(); if let Ok(_) = config_file.read_to_string(&mut config_data) { - config = toml::decode_str(&config_data).unwrap_or(Config::default()); + config = toml::from_str(&config_data).unwrap_or(Config::default()); } } } -- GitLab