objc2-messages 0.3.2

Bindings to the Messages framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// The MSMessage encapsulates the data to be transferred to remote devices.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/messages/msmessage?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MSMessage;
);

extern_conformance!(
    unsafe impl NSCoding for MSMessage {}
);

extern_conformance!(
    unsafe impl NSCopying for MSMessage {}
);

unsafe impl CopyingHelper for MSMessage {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MSMessage {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for MSMessage {}
);

impl MSMessage {
    extern_methods!(
        /// Initializes a new message that is not part of a session.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "MSSession")]
        /// Initializes a message with a session.
        ///
        /// See: insertMessage:completionHandler:
        ///
        /// Parameter `session`: The session that new message will join.
        ///
        /// A message initialized with a session will be updated
        /// and moved to the bottom of the conversation transcript when another message created
        /// with the same session is sent.
        #[unsafe(method(initWithSession:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSession(this: Allocated<Self>, session: &MSSession)
            -> Retained<Self>;

        #[cfg(feature = "MSSession")]
        /// An MSSession that identifies the session that message belongs to.
        #[unsafe(method(session))]
        #[unsafe(method_family = none)]
        pub unsafe fn session(&self) -> Option<Retained<MSSession>>;

        /// A BOOL representing whether the message is a pending message or is a message that has been sent/received.
        ///
        /// This value starts as `YES` when creating an `MSMessage` for sending. After calling `-[MSConversation insertMessage:completionHandler:]`, `isPending` still returns `YES` until `-[MSMessagesAppViewController didStartSendingMessage:conversation]` is called. This property is useful for knowing if the `selectedMessage` of `-[MSMessagesAppViewController activeConversation]` represents an unsent message.
        #[unsafe(method(isPending))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPending(&self) -> bool;

        /// A NSUUID instance that identifies the participant that sent the message.
        ///
        /// This NSUUID identifies the message's sender. This value is scoped to
        /// the current device and will be different on all devices that participate in the
        /// conversation.
        #[unsafe(method(senderParticipantIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn senderParticipantIdentifier(&self) -> Retained<NSUUID>;

        #[cfg(feature = "MSMessageLayout")]
        /// A subclass of MSMessageLayout.
        ///
        /// The MSMessageLayout subclass will be used to construct UI
        /// representing the message in the conversation transcript.
        #[unsafe(method(layout))]
        #[unsafe(method_family = none)]
        pub unsafe fn layout(&self) -> Option<Retained<MSMessageLayout>>;

        #[cfg(feature = "MSMessageLayout")]
        /// Setter for [`layout`][Self::layout].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLayout:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLayout(&self, layout: Option<&MSMessageLayout>);

        /// A HTTP(S) or data URL used to encode data to be transferred in message.
        ///
        /// This URL should encode any data that is to be delivered to the extension running
        /// on the recipient's device(s). When no app exists on the receiving device that
        /// can consume the message, if this URL is a HTTP(S) url, it will be loaded in a web browser.
        #[unsafe(method(URL))]
        #[unsafe(method_family = none)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;

        /// Setter for [`URL`][Self::URL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setURL(&self, url: Option<&NSURL>);

        /// A Boolean value that indicates whether the messages should expire after being read.
        ///
        /// YES if the message should expire after it is read. Expired messages will
        /// be deleted a short time after being read by the receiver. The user may opt to keep the message.
        /// This property defaults to NO.
        #[unsafe(method(shouldExpire))]
        #[unsafe(method_family = none)]
        pub unsafe fn shouldExpire(&self) -> bool;

        /// Setter for [`shouldExpire`][Self::shouldExpire].
        #[unsafe(method(setShouldExpire:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShouldExpire(&self, should_expire: bool);

        /// A localized string describing the message.
        ///
        /// This string should provide a succinct description of the message. This
        /// will be used by the Accessibility Speech feature when speaking the message for users
        /// with disabilities.
        #[unsafe(method(accessibilityLabel))]
        #[unsafe(method_family = none)]
        pub unsafe fn accessibilityLabel(&self) -> Option<Retained<NSString>>;

        /// Setter for [`accessibilityLabel`][Self::accessibilityLabel].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAccessibilityLabel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAccessibilityLabel(&self, accessibility_label: Option<&NSString>);

        /// A localized string describing the message.
        ///
        /// This string should provide a succinct description of the message. This
        /// will be used to provide a summary of the message in the UI.
        #[unsafe(method(summaryText))]
        #[unsafe(method_family = none)]
        pub unsafe fn summaryText(&self) -> Option<Retained<NSString>>;

        /// Setter for [`summaryText`][Self::summaryText].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSummaryText:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSummaryText(&self, summary_text: Option<&NSString>);

        /// An error object that indicates why a message failed to send.
        ///
        /// This value is nil if the message is has not yet been sent, is still
        /// sending or has been sent successfully.
        #[unsafe(method(error))]
        #[unsafe(method_family = none)]
        pub unsafe fn error(&self) -> Option<Retained<NSError>>;

        /// Setter for [`error`][Self::error].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setError:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setError(&self, error: Option<&NSError>);
    );
}

/// Methods declared on superclass `NSObject`.
impl MSMessage {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}