Replies: 1 comment
-
Old issue but I was able to figure it out: use http_body::Body;
if let Ok(constants_updates) = octocrab
.repos("foo", "bar")
.raw_file(Reference::Branch("main".to_string()), "data/latest.json")
.await
{
let mut body = constants_updates.into_body();
let mut result = Vec::with_capacity(body.size_hint().exact().unwrap_or_default() as usize);
// Iterate through all data chunks in the body
while let Some(frame) = body.frame().await {
match frame {
Ok(frame) => {
if let Some(data) = frame.data_ref() {
result.extend_from_slice(&data);
}
}
Err(_) => return None,
}
}
Some(result))
} else {
None
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to get https://github.com/beyarkay/eskom-calendar/blob/main/manually_specified.yaml as a
String
or&str
so that I can parse the YAML and edit it. How do I do this? I've tried:And that gets me a
hyper::Body
object, but I can't figure out how to extract the content from it. I've tried to look online, but all the answers 1 2 3 4 suggest things that don't work with the latest version of hyper.Is it possible to get the raw text of a file hosted on github? I've resorted to using
reqwest
and just downloading the raw.githubusercontent.com version of the file, but theraw_file
method sounds like it should be able to give me the raw file.Beta Was this translation helpful? Give feedback.
All reactions