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

Exclude setting "async-std" and "tokio" features at the same time. #164

Open
luukvanderduim opened this issue Mar 17, 2024 · 3 comments
Open

Comments

@luukvanderduim
Copy link
Collaborator

In atspi/src/lib.rs
https://github.com/odilia-app/atspi/blob/c3338f4373ca5c0240e7dc9d3fddf832e102ecaf/atspi/src/lib.rs#L10C1-L11C89

#[cfg(all(not(feature = "async-std"), not(feature = "tokio")))]
compile_error!("You must specify at least one of the `async-std` or `tokio` features.");

This warns us when neither "async-std" or "tokio" is set.

What about having both set?
This could easily happen I were to

[dependencies]
atspi = { version = "0.22", features = ["connection-tokio"] } 

I believe this leads to having the default feature "async-std" set as well as "tokio". Right?
Is there a way to unset one if the other is set automatically and vice versa?

@TTWNO
Copy link
Member

TTWNO commented Mar 17, 2024

Yes... I think you're right about that.

No, I don't think you can disable a festure when another is enabled.

@TTWNO
Copy link
Member

TTWNO commented Mar 17, 2024

I think this was changed when async-std and tokio were both allowed as features of zbus. And I said "oh good! now I don't have to worry about atspi having both either!"

But I think you're right to be concrrned here.

@luukvanderduim
Copy link
Collaborator Author

I have consulted the zbus sources:
This seems to affect error_message only - I think?

#[cfg(all(not(feature = "async-io"), not(feature = "tokio")))]
mod error_message {
    #[cfg(windows)]
    compile_error!("Either \"async-io\" (default) or \"tokio\" must be enabled. On Windows \"async-io\" is (currently) required for UNIX socket support");

    #[cfg(not(windows))]
    compile_error!("Either \"async-io\" (default) or \"tokio\" must be enabled.");
}

I did find instances like:

    /// Runs a single task.
    ///
    /// With `tokio` feature enabled, its a noop and never returns.
    pub async fn tick(&self) {
        #[cfg(not(feature = "tokio"))]
        {
            self.executor.tick().await
        }

        #[cfg(feature = "tokio")]
        {
            pending().await
        }
    }

At first glance I'd say it is unreasonable to allow both enabled.
I will try to enable both in a test program and break something and make lots of drama elsewhere ;')

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