1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use extern::base64;
use extern::burgundy;
use types;
lazy_static! {
static ref GITHUB_BASE64_CONFIG : base64::Config = base64::Config::new(
base64::CharacterSet::Standard,
true,
true,
base64::LineWrap::Wrap(60, base64::LineEnding::LF),
);
}
pub struct GithubGetReposOwnerRepoContentsPath {
crate path: burgundy::Path,
}
impl GithubGetReposOwnerRepoContentsPath {
pub fn run(self) -> burgundy::Result<types::Contents> {
self.path.execute_as_json()
}
pub fn run_and_decode(self) -> burgundy::Result<types::Contents> {
let mut file = self.run()?;
let decoded_content = base64::decode_config(&file.content, *GITHUB_BASE64_CONFIG).unwrap();
let decoded_content_str = String::from_utf8(decoded_content).unwrap();
file.content = decoded_content_str;
Ok(file)
}
}