sfackler / rust-openssl

OpenSSL bindings for Rust
1.37k stars 738 forks source link

Using openssl with openssl-sys #2020

Open dhouck opened 1 year ago

dhouck commented 1 year ago

Thereʼs a function in the C OpenSSL library I might want to use, which doesnʼt have bindings in rust-openssl and where it probably doesnʼt make sense to add bindings (it is deliberately part of the API, but undocumented, and I bet very few people want to use it).

When I try to call as_ptr on the various openssl types implementing ForeignType, I get an error that I need to use the trait first. I might be missing something, but I think this is not accessible through this crate, so I need to explicitly depend on the correct version of foreign-types-shared for it?

If thatʼs the case, then either there should be a better way to call those functions, or the trait should be re-exported; I shouldnʼt need to know internal implementation details to use functions documented in the public API. Alternately, they should not be documented if my use case is not supported.

sfackler commented 1 year ago

You can find the foreign-types version in openssl's dependencies list: https://github.com/sfackler/rust-openssl/blob/master/openssl/Cargo.toml#L28.

It isn't an implementation detail; it's part of the public API.

dhouck commented 1 year ago

In that case I feel like it should be pub used somewhere so that consumers donʼt need to worry about keeping the crate in sync themselves, especially if they might want to use a different version themselves. Would you be open to a PR that did that, and if so can you think of other things that might want to be treated similarly?

sfackler commented 1 year ago

That seems reasonable to me, sure.