sfackler / rust-native-tls

Apache License 2.0
474 stars 199 forks source link

impl common traits for public facing types #207

Closed garritfra closed 3 years ago

garritfra commented 3 years ago

I'm working on implementing common traits for public facing types

Unfortunately this doesn't seem trivial, since some types are declared using the declare_TCFType macro, so deriving them is not possible. I tried implementing them by hand, but this doesn't seem to have an effect.

Implementation of traits for `SecIdentity` ```rs declare_TCFType! { /// A type representing an identity. /// /// Identities are a certificate paired with the corresponding private key. SecIdentity, SecIdentityRef } impl_TCFType!(SecIdentity, SecIdentityRef, SecIdentityGetTypeID); impl Copy for SecIdentity {} impl Clone for SecIdentity {} impl Eq for SecIdentity {} impl PartialEq for SecIdentity {} impl Ord for SecIdentity {} impl PartialOrd for SecIdentity {} impl Hash for SecIdentity {} impl Debug for SecIdentity {} impl Default for SecIdentity {} ```
Error describing that `SecIdentity` doesn't implement `Copy` ``` error[E0204]: the trait `Copy` may not be implemented for this type --> src/imp/security_framework.rs:78:10 | 78 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] | ^^^^ 79 | pub struct Identity { 80 | identity: SecIdentity, | --------------------- this field does not implement `Copy` 81 | chain: Vec, | -------------------------- this field does not implement `Copy` | = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) ```

I must say that I'm not familiar with this macro, so it could just be that I'm missing something. Do you know a way around this issue?

Thanks for feedback of any kind!

Related: #146

sfackler commented 3 years ago

This seems like a question for https://github.com/kornelski/rust-security-framework

garritfra commented 3 years ago

Oh sorry, I was a bit confused about the project structure. Here's the corresponding issue. I'll open a PR once this is resolved.