-
Notifications
You must be signed in to change notification settings - Fork 21
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
Rework context construction #12
Rework context construction #12
Conversation
the Backend will be used in conjunction with the new constructor to instantiate IIO devices. This will make it more clear which Backends (i.e. URIs) are supported, and it unifies the interface for COntext creation.
The constructor takes a Variant of `Backend` as parameter to create an IIO context.
These functions are now obsoleted by the `new` constructor. The previous `new` is renamed to `default` to retain some degree of compatibility with respect to the ENV-variable based backend selection.
Yeah, I'm always conflicted when writing a library like this about how close to stick to the C API. The Backend enum looks like a good idea, although I might think to keep a few "obsolete" functions for at least the more common use cases to try and keep apps succinct, although, keeping things more idiomatic, maybe it would be better to drop the "create" and just use
I'll have a closer look and comment in a day or two. First, though, since this is a breaking API change, I want to push out the code that has been sitting unreleased in master as v0.3, and then this can be the start of v0.4. |
BTW, I merged as-is, but we can consider some changes before moving to a release. Some things I'm thinking:
|
Oh, I see! I wasn't aware of that, I just thought that's a reasonable name for the particular function...
Good point. I just did it this way as it seemed less "repetitive", because now I just create a backend-specific URI and pass all URIs to the same underlying function. But that's a rather quick thing to fix.
True, I completely missed that, sorry!
That's what I would have preferred, but from a quick search I couldn't find any info on how to use the cfg macro to exclude particular members of an enum... Next time I will mark the PR as WIP and ask. Sorry for the inconveniences! If I find some time in the next few days I'll attempt to clean it up. |
No worries. I appreciate the help and fresh ideas. I spent the day on it yesterday, and got a lot of this cleaned up. Let me know what you think. I probably have a few days to focus on this project, then I'll need to move on to some other work. |
Looks good! I think that I personally would prefer to have Thanks for cleaning up all the bits! |
I think the enum for the back-ends works pretty well in this case, but for a struct that can be created with so many different options, trying to stretch an enum into a single So I think we're on track now. |
Hello,
this is an attempt to "streamline" the default Context construction. I don't mean to be rude, but from what I've seen so far, the usual way to generate instances of "objects" is by defining a
new
function/method. I thought that as this is a Rust library, maybe it could use a more Rust-specific way of instantiating objects... ?Personally, as a newcomer that hasn't worked with the IIO C-library before, I found it really confusing that there are 5 or 6 different functions to generate a context. So I added an Enum for the various backend types that IIO understands and pass these as parameter to the
new
function.I'm aware that this is a breaking change with respect to the current interface. Curious to hear your thoughts on the issue!
Cheers,
Andreas