docs(helpers): Let service account and helper code show up in rustdoc

This commit is contained in:
Lewin Bormann
2016-09-21 08:37:14 +02:00
parent 1c1880cfe7
commit 624a202464
2 changed files with 8 additions and 2 deletions

View File

@@ -11,20 +11,23 @@ use serde_json;
use std::io::{self, Read};
use std::fs;
use std::path::Path;
use service_account::ServiceAccountKey;
use types::{ConsoleApplicationSecret, ApplicationSecret};
pub fn read_application_secret(file: &String) -> io::Result<ApplicationSecret> {
/// Read an application secret from a file.
pub fn read_application_secret(path: &Path) -> io::Result<ApplicationSecret> {
use std::io::Read;
let mut secret = String::new();
let mut file = try!(fs::OpenOptions::new().read(true).open(file));
let mut file = try!(fs::OpenOptions::new().read(true).open(path));
try!(file.read_to_string(&mut secret));
parse_application_secret(&secret)
}
/// Read an application secret from a JSON string.
pub fn parse_application_secret(secret: &String) -> io::Result<ApplicationSecret> {
let result: serde_json::Result<ConsoleApplicationSecret> = serde_json::from_str(secret);
match result {
@@ -45,6 +48,8 @@ pub fn parse_application_secret(secret: &String) -> io::Result<ApplicationSecret
}
}
/// Read a service account key from a JSON file. You can download the JSON keys from the Google
/// Cloud Console or the respective console of your service provider.
pub fn service_account_key_from_file(path: &String) -> io::Result<ServiceAccountKey> {
let mut key = String::new();
let mut file = try!(fs::OpenOptions::new().read(true).open(path));

View File

@@ -31,3 +31,4 @@ pub use authenticator::{Authenticator, Retry, GetToken};
pub use authenticator_delegate::{AuthenticatorDelegate, DefaultAuthenticatorDelegate, PollError,
PollInformation};
pub use helper::*;
pub use service_account::*;