-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement serialization feature-flag
- Loading branch information
1 parent
ae732aa
commit 825fb54
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extern crate libc; | ||
extern crate rctl; | ||
|
||
#[cfg(feature="serialize")] | ||
extern crate serde_json; | ||
|
||
#[cfg(feature="serialize")] | ||
fn main() { | ||
|
||
let uid = unsafe { libc::getuid() }; | ||
|
||
let subject = rctl::Subject::user_id(uid); | ||
|
||
let serialized = serde_json::to_string(&subject) | ||
.expect("Could not serialize RCTL subject."); | ||
|
||
println!("{}", serialized); | ||
} | ||
|
||
#[cfg(not(feature="serialize"))] | ||
fn main() { | ||
println!("Run `cargo build --features=serialize` to enable this example"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters