Rust errors are hard to figure out -- trying to download a tarball from GitHub

First time Rust learner here. Task, simple: download a tarball into the local filesystem using the Rust implementation of the GitHub REST API, as defined in REST API endpoints for repository contents - GitHub Docs

The community has written a Rust library for accessing this API. Great! I try to use the function, which returns a Result<http::Response<hyper::Body>>

Fair enough, I try to see how I can turn that into the actual ZIP. I look around in the tests and online, and eventually I find the hyper to_bytes() function. Great!

Oops. It's been deprecated. I ask ChatGPT. Nothing -- it doesn't know anything about the deprecation or how to work around it.

I have given up. I open an issue, forgot about it for a minute, and today, I tried the solution I was given there.

Except, it doesn't work. Here's the error I get:

error[E0599]: the method `frame` exists for mutable reference `&mut Body`, but its trait bounds were not satisfied
  --> src/repos/
85 |         while let Some(next) = body.frame().await {
   |                                     ^^^^^ method cannot be called on `&mut Body` due to unsatisfied trait bounds
  ::: /Users/winston/.asdf/installs/rust/1.76.0/registry/src/
38 | pub struct Body {
   | ---------------
   | |
   | doesn't satisfy `hyper::body::body::Body: BodyExt`
   | doesn't satisfy `hyper::body::body::Body: hyper::body::Body`
   = note: the following trait bounds were not satisfied:
           `hyper::body::body::Body: hyper::body::Body`
           which is required by `hyper::body::body::Body: BodyExt`
           `&mut hyper::body::body::Body: hyper::body::Body`
           which is required by `&mut hyper::body::body::Body: BodyExt`

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
  --> src/repos/
87 |             if let Some(chunk) = frame.data_ref() {
   |                         ^^^^^ doesn't have a size known at compile-time
   = help: the trait `Sized` is not implemented for `[u8]`
   = note: all local variables must have a statically known size
   = help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
  --> src/repos/
87 |             if let Some(chunk) = frame.data_ref() {
   |                    ^^^^^^^^^^^ doesn't have a size known at compile-time
   = help: the trait `Sized` is not implemented for `[u8]`
note: required by a bound in `std::prelude::v1::Some`
  --> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/

If anything's worse than the fact that this code seems to have mysteriously failed between the helpful commenter providing it and me copying it to my machine, it's that error message. I hear so many great things about Rust and how helpful the compiler is, but this has been a true exercise in futility over the last few weeks.

  1. How can I fix my tarball-downloading code once and for all? Am I missing some feature of some crate?
  2. Can I make my Rust journey easier? Am I doing something fundamentally wrong??

With the same code from there, everything works fine.

octocrab = "0.34.3"
tokio = { version = "1", features = ["full"] }
http-body-util = "0.1"
use http_body_util::BodyExt;
use std::fs::File;
use std::io::Write;

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let octocrab = octocrab::instance();
    let mut resp = octocrab
        .repos("XAMPPRocky", "octocrab")
    let body = resp.body_mut();

    let mut file = File::create("test.tar.gz")?;

    while let Some(next) = body.frame().await {
        let frame = next?;
        if let Some(chunk) = frame.data_ref() {

For these lines, your hyper version is too old. There is no hyper::body::body::Body since hyper1.0.
Maybe you can try cargo update to update your deps.

Thank you, seems to have worked. What are some things I can do to prevent future frustrating issues like this when I encounter them?

Another question would be why is my VS Code/Rust setup extremely unstable? It is regularly wrong and fails to produce helpful autocomplete suggestions. As a beginner, this would be good: but in the example above, for example, it seems to think file's is a (), when it is clearly a Result<File>:


Actually, if no one told me body.frame().await, I could never know it by myself.

I don't have general advice for solving Rust error.

Rust errors are good in general, the first step is to think why the compiler reports it by saying the trait bound is not met.

Did you use the latest Rust-Analyzer?

Did you use the latest Rust-Analyzer?

Yes, I have tried both the pre-release and release version.

My experience is that compiler errors are only occasionally unhelpful. Can you give example? Or say what you mean by regularly?

In general I fond Rust compiler to be very helpful.

Where life gets confusing is when one finds oneself trying to use an old version of some crate or does not have a crates features enabled etc. Then an error that would be very helpful if it were ones own code becomes confusing as one has no idea about the crate. Likely it's asking a bit much to expect the compiler to know these things and suggest newer versions and so on.

As for rust-analyser in VSCode I have no idea, again generally it "just works" and is very helpful. It's a long time since I hade any trouble with it.

Here's another one:

qualifying is clearly a vec, but I get no autocomplete suggestions with it as a result of the unknown type. This is a 20-line program and it is broken with a capital B. It turns me away from Rust as it is hard to learn a language this way!


I'm afraid if one is having difficulty learning Rust it will not be possible or at least very hard for anyone here to help unless one can clearly state exactly what the problem is.

It would greatly help if one could post actual source code here instead of a screen shot, that way people can try out whatever it is that is causing the difficulty.

It would help to state exactly what one is doing or any errors that occur.

From what I understand of your problem you are not getting autocomplete suggestions when your tying gets to something like:

    let qualifying: Vec<(LogMeta, Value)> = vec![];

I am using VSCode and rust-analyser and I do get auto-complete suggestions at that point. In my case Value is known from serde_json but LogMeta is not.

So, what actually is the problem? What editor is that? Are you using rust-analyser?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.