pub unsafe trait Message: RefEncode { }Expand description
Types that can be sent Objective-C messages.
Implementing this provides MessageReceiver implementations for common
pointer types and references to the type, which allows using them as the
receiver (first argument) in the msg_send! macro.
This trait also allows the object to be used in rc::Id.
This is a subtrait of RefEncode, meaning the type must also implement
that, almost always as Encoding::Object.
Safety
The type must represent an Objective-C object, meaning it:
- Must be valid to reinterpret as 
runtime::Object. - Must be able to be the receiver of an Objective-C message sent with
objc_msgSendor similar. - Must respond to the standard memory management 
retain,releaseandautoreleasemessages. 
Example
use objc2::runtime::Object;
use objc2::{Encoding, Message, RefEncode};
#[repr(C)]
struct MyObject {
    // This has the exact same layout as `Object`
    inner: Object
}
unsafe impl RefEncode for MyObject {
    const ENCODING_REF: Encoding = Encoding::Object;
}
unsafe impl Message for MyObject {}
// `*mut MyObject` and other pointer/reference types to the object can
// now be used in `msg_send!`
//
// And `Id<MyObject, O>` can now be constructed.