Skip to content

How to call async functions? #91

@mattiasflodin

Description

@mattiasflodin

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions