Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call async functions? #91

Open
mattiasflodin opened this issue Jul 8, 2023 · 1 comment
Open

How to call async functions? #91

mattiasflodin opened this issue Jul 8, 2023 · 1 comment

Comments

@mattiasflodin
Copy link

mattiasflodin commented Jul 8, 2023

It is not clear to me from the documentation how any of the async functions should be used. The documentation for AsyncDisplay says "It can do everything that a Display can do, but it doesn’t block and return values. Instead, it returns a Future". Apparently AsyncDisplay is implemented for BasicDisplay. The functions appear to live in AsyncDisplayFunctionsExt (which is in the prelude), but confusingly they are not in scope for an instance of BasicDisplay. Here is my test code which is the best I've been able to figure out so far.

use breadx::display::{DisplayBase, DisplayConnection, AsyncDisplay, CanBeAsyncDisplay};
use breadx::prelude::*;

pub(crate) async fn foo(conn: &mut DisplayConnection) {
    AsyncDisplayFunctionsExt::intern_atom_immediate(conn, false, b"foo").await.unwrap();
}

This generates the error:

error[E0277]: the trait bound `BasicDisplay<BufConnection<NameConnection>>: AsyncDisplay` is not satisfied
     --> src/test.rs:5:53
      |
5     |     AsyncDisplayFunctionsExt::intern_atom_immediate(conn, false, b"foo").await.unwrap();
      |     ----------------------------------------------- ^^^^ the trait `AsyncDisplay` is not implemented for `BasicDisplay<BufConnection<NameConnection>>`
      |     |
      |     required by a bound introduced by this call
      |
      = help: the following other types implement trait `AsyncDisplay`:
                &CellDisplay<Dpy>
                &mut D
                Box<D>
                CellDisplay<Dpy>

Can you please provide examples or documentation for how to use these functions?

@notgull
Copy link
Member

notgull commented Jul 8, 2023

Have you read through one of the async samples? I think they explain how async calls work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants