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

[yang3] into_raw for Bindings #21

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

yodaldevoid
Copy link
Contributor

This adds an Bindings::into_raw to allow turning any Binding into its raw pointer.

I need this as I am modifying sysrepo-rs to remove all libyang bindings, replacing them with the ones from this crate.

@yodaldevoid yodaldevoid changed the title into_raw for Bindings [yang3] into_raw for Bindings Dec 1, 2024
@yodaldevoid
Copy link
Contributor Author

The failing CI tests are unrelated to this PR and are fixed in #24.

Copy link
Member

@rwestphal rwestphal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Please see the inline review comments.

Overall, some yang-rs types own data, while others are simple references. So the semantics of into_raw isn't always clear, for some types as_raw would be more appropriate. We could potentially implement either into_raw or as_raw directly on the types instead of having the into_raw trait method. What do you think?

src/data.rs Outdated Show resolved Hide resolved
src/data.rs Outdated Show resolved Hide resolved
@yodaldevoid
Copy link
Contributor Author

What do you think?

Seems reasonable to me. I had a feeling that this wasn't quite right, but had to start somewhere. I'll try to figure out where to implement as_raw and where to implement into_raw, but some guidance would be wonderful.

@yodaldevoid yodaldevoid force-pushed the to_raw branch 2 times, most recently from 58669cf to 6b06826 Compare December 8, 2024 20:55
src/data.rs Outdated Show resolved Hide resolved
Adds methods to get the raw pointer to the libyang structures held by
many structures. into_raw has been implemented where the struct manages
the pointer (has a Drop impl to free/release the internal struture),
and as_raw has been implemented where the struct is just a wrapper.
Copy link
Member

@rwestphal rwestphal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thank you!

@rwestphal rwestphal merged commit f812bdd into holo-routing:master Dec 10, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants