Skip to content

How to use stabby futures #56

@kylezs

Description

@kylezs

It's not clear to me what's meant by the comment on the futures module.

/// Futures can be ABI-stable if you wish hard enough
#[cfg_attr(
    feature = "unsafe_wakers",
    deprecated = "Warning! you are using the `stabby/unsafe_wakers` feature. This could cause UB if you poll a future received from another shared library with mismatching ABI! (this API isn't actually deprecated)"
)]

I've currently got a simple entry point that returns a future:

#[stabby::import(name = "first_shared_lib", canaries = "none")]
extern "C" {
    fn entry_point(
        args: crate::MyArgsMirror,
    ) -> stabby::future::DynFuture<'static, stabby::result::Result<(), ()>>;
}

This works, the code is called and returned correctly (nb: both are compiled with the same version here, but they won't necessarily be in the future - hence I'm trying to use stabby) - however I get a warning:

warning: `extern` block uses type `RawWaker`, which is not FFI-safe
  --> runner/src/main.rs:14:10
   |
14 |     ) -> stabby::future::DynFuture<'static, stabby::result::Result<(), ()>>;
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout
   = note: `#[warn(improper_ctypes)]` on by default

What's the intended way for this to work? Are there more detailed examples somewhere?

Thanks!

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