Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liam Naddell
drivers
Commits
466c776b
Commit
466c776b
authored
Apr 23, 2017
by
Jeremy Soller
Committed by
GitHub
Apr 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10 from kaedroho/feature/serde
Migrate to serde. Fixes #9
parents
b3849ddf
520c140d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
pcid/Cargo.toml
pcid/Cargo.toml
+3
-2
pcid/src/config.rs
pcid/src/config.rs
+2
-2
pcid/src/main.rs
pcid/src/main.rs
+3
-2
No files found.
pcid/Cargo.toml
View file @
466c776b
...
@@ -4,5 +4,6 @@ version = "0.1.0"
...
@@ -4,5 +4,6 @@ version = "0.1.0"
[dependencies]
[dependencies]
redox_syscall
=
"0.1"
redox_syscall
=
"0.1"
rustc-serialize
=
"0.3"
serde
=
"1.0"
toml
=
"0.2"
serde_derive
=
"1.0"
toml
=
"0.4"
pcid/src/config.rs
View file @
466c776b
#[derive(Debug,
Default,
RustcDecodabl
e)]
#[derive(Debug,
Default,
Deserializ
e)]
pub
struct
Config
{
pub
struct
Config
{
pub
drivers
:
Vec
<
DriverConfig
>
pub
drivers
:
Vec
<
DriverConfig
>
}
}
#[derive(Debug,
Default,
RustcDecodabl
e)]
#[derive(Debug,
Default,
Deserializ
e)]
pub
struct
DriverConfig
{
pub
struct
DriverConfig
{
pub
name
:
Option
<
String
>
,
pub
name
:
Option
<
String
>
,
pub
class
:
Option
<
u8
>
,
pub
class
:
Option
<
u8
>
,
...
...
pcid/src/main.rs
View file @
466c776b
#![deny(warnings)]
#![deny(warnings)]
#![feature(asm)]
#![feature(asm)]
extern
crate
rustc_serialize
;
extern
crate
serde
;
#[macro_use]
extern
crate
serde_derive
;
extern
crate
syscall
;
extern
crate
syscall
;
extern
crate
toml
;
extern
crate
toml
;
...
@@ -25,7 +26,7 @@ fn main() {
...
@@ -25,7 +26,7 @@ fn main() {
if
let
Ok
(
mut
config_file
)
=
File
::
open
(
&
config_path
)
{
if
let
Ok
(
mut
config_file
)
=
File
::
open
(
&
config_path
)
{
let
mut
config_data
=
String
::
new
();
let
mut
config_data
=
String
::
new
();
if
let
Ok
(
_
)
=
config_file
.read_to_string
(
&
mut
config_data
)
{
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
());
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment