Expand description
Types whoose references has an Objective-C type-encoding.
Implementing this for T
provides Encode
implementations for:
*const T
*mut T
&T
&mut T
NonNull<T>
Option<&T>
Option<&mut T>
Option<NonNull<T>>
External crates cannot implement Encode
for pointers or Option
s
containing references, so instead, they can implement this trait.
Additionally it would be very cumbersome if every type had to implement
Encode
for all possible pointer types.
Finally, having this trait allows for much cleaner generic code that need
to represent types that can be encoded as pointers.
References to the object must be FFI-safe.
See the nomicon entry on representing opaque structs for
information on how to represent objects that you don’t know the layout of
(or use extern type
(RFC-1861) if you’re using nightly).
Objective-C will make assumptions about the type (like its size and
alignment) from its encoding, so the implementer must verify that the
encoding is accurate.
Concretely, Self::ENCODING_REF
must match the result of running
@encode
in Objective-C with a pointer to the type in question.
impl<Ret, A, B, C, D, E> RefEncode for unsafe extern "C" fn(A, B, C, D, E) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
impl<Ret, A, B, C, D> RefEncode for extern "C" fn(A, B, C, D) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
impl<Ret, A, B, C, D, E> RefEncode for extern "C" fn(A, B, C, D, E, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
impl<Ret, A, B, C, D, E, F, G> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, L, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
L: Encode,
impl<Ret, A, B, C, D, E, F, G, H> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
impl<Ret, A, B, C, D, E> RefEncode for unsafe extern "C" fn(A, B, C, D, E, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
impl<Ret, A, B, C> RefEncode for extern "C" fn(A, B, C, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
impl<Ret, A, B, C, D, E, F> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, I, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
impl<Ret, A, B, C, D, E, F> RefEncode for extern "C" fn(A, B, C, D, E, F) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
impl<Ret, A, B, C, D, E, F, G, H> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
impl<Ret, A, B, C, D> RefEncode for extern "C" fn(A, B, C, D, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
impl<Ret, A, B, C, D, E, F, G, H> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
impl<Ret, A, B, C, D> RefEncode for unsafe extern "C" fn(A, B, C, D) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, I, J, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
impl<Ret, A, B, C, D, E> RefEncode for extern "C" fn(A, B, C, D, E) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, I) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
impl<Ret, A, B, C, D, E, F, G> RefEncode for extern "C" fn(A, B, C, D, E, F, G, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, L, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
L: Encode,
impl<Ret, A, B, C, D> RefEncode for unsafe extern "C" fn(A, B, C, D, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
impl<Ret, A, B, C, D, E, F, G> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
impl<Ret, A, B, C, D, E, F> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
impl<Ret, A, B, C, D, E, F> RefEncode for extern "C" fn(A, B, C, D, E, F, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
impl<Ret, A, B, C, D, E, F, G, H> RefEncode for extern "C" fn(A, B, C, D, E, F, G, H, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
impl<Ret, A, B, C> RefEncode for unsafe extern "C" fn(A, B, C, ...) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I, J, K, L) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
J: Encode,
K: Encode,
L: Encode,
impl<Ret, A, B, C, D, E, F, G, H, I> RefEncode for unsafe extern "C" fn(A, B, C, D, E, F, G, H, I) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,
H: Encode,
I: Encode,
impl<Ret, A, B, C, D, E, F, G> RefEncode for extern "C" fn(A, B, C, D, E, F, G) -> Ret where
Ret: Encode,
A: Encode,
B: Encode,
C: Encode,
D: Encode,
E: Encode,
F: Encode,
G: Encode,