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

Make SinkInfo, ServerInfo, and similar types available outside of callbacks #44

Open
agraven opened this issue Sep 24, 2021 · 4 comments

Comments

@agraven
Copy link
Contributor

agraven commented Sep 24, 2021

The types listed in the title all share the issue that when you receive them in callbacks passed to methods like get_sink_info_by_name, you can't use those types outside of the callbacks due to lifetime constraints.

I first tried to address the issue by deriving Clone for the relevant structs, but I realized that won't solve the problem since cloning a Cow::Borrowed just produces a copy of the reference it contains. I next tried to see if the derive-into-owned crate would work, but the derive seems to fail on some types, for example SinkInfo.

@jnqnfe
Copy link
Owner

jnqnfe commented Oct 15, 2021

Sorry for the delay, I'll try to take a look at it all soon. I'm not ignoring you :)

@agraven
Copy link
Contributor Author

agraven commented Oct 15, 2021

No worries, I've been quite busy myself as well :)

@j4w3ny
Copy link

j4w3ny commented Jan 28, 2022

Looking for the support of that as well :)

@acheronfail
Copy link

acheronfail commented Apr 26, 2023

I've just started extensively using this crate, and the ergonomics of the API are difficult around these borrowed structs.
Since there's no public way to copy/clone them, we can only read them during the closures, and that makes it very difficult to consume...

For those curious, my workaround was to copy all of the structs, or create wrappers for some of them, and then inside the closures create instances of my struct copies. This isn't nice at all - if this crate changes anything then it'll break my structs, but it works for me for now.

I'm all for something like #43 - but instead of using a fork of this project with that addition (or just straight up duplicating the structs themselves), can we instead make some changes here? 🙏

acheronfail added a commit to acheronfail/pulse-rs that referenced this issue Apr 27, 2023
…ucts

Problems were mainly from:

* jnqnfe/pulse-binding-rust#44 (borrow issues)
* structs not exposing all the data needed
* some structs can't be constructed themselves, but need to be coerced
* we don't have access to the underlying variants of some of the enums,
  so we have to rely on some ugly hacks (using Debug representations, etc)
acheronfail added a commit to acheronfail/pulse-rs that referenced this issue Apr 27, 2023
* jnqnfe/pulse-binding-rust#44 (borrow issues)
* structs not exposing all the data needed
* some structs can't be constructed themselves, but need to be coerced
* we don't have access to the underlying variants of some of the enums,
  so we have to rely on some ugly hacks (using Debug representations, etc)
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

4 participants