objc2-mail-kit 0.3.2

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

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/mailkit/memessagestate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MEMessageState(pub NSInteger);
impl MEMessageState {
    #[doc(alias = "MEMessageStateReceived")]
    pub const Received: Self = Self(0);
    #[doc(alias = "MEMessageStateDraft")]
    pub const Draft: Self = Self(1);
    #[doc(alias = "MEMessageStateSending")]
    pub const Sending: Self = Self(2);
}

unsafe impl Encode for MEMessageState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MEMessageState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/mailkit/memessageencryptionstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MEMessageEncryptionState(pub NSInteger);
impl MEMessageEncryptionState {
    #[doc(alias = "MEMessageEncryptionStateUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "MEMessageEncryptionStateNotEncrypted")]
    pub const NotEncrypted: Self = Self(1);
    #[doc(alias = "MEMessageEncryptionStateEncrypted")]
    pub const Encrypted: Self = Self(2);
}

unsafe impl Encode for MEMessageEncryptionState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MEMessageEncryptionState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Contains information about a mail message on which actions can be performed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/mailkit/memessage?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MEMessage;
);

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

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

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

impl MEMessage {
    extern_methods!(
        /// The state of the mail message.
        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub unsafe fn state(&self) -> MEMessageState;

        /// The encryption state of the mail message.
        #[unsafe(method(encryptionState))]
        #[unsafe(method_family = none)]
        pub unsafe fn encryptionState(&self) -> MEMessageEncryptionState;

        /// The subject of the mail message.
        #[unsafe(method(subject))]
        #[unsafe(method_family = none)]
        pub unsafe fn subject(&self) -> Retained<NSString>;

        #[cfg(feature = "MEEmailAddress")]
        /// Message sender's email address.
        #[unsafe(method(fromAddress))]
        #[unsafe(method_family = none)]
        pub unsafe fn fromAddress(&self) -> Retained<MEEmailAddress>;

        #[cfg(feature = "MEEmailAddress")]
        /// Recipient email addresses in the "To" address field of the message.
        #[unsafe(method(toAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn toAddresses(&self) -> Retained<NSArray<MEEmailAddress>>;

        #[cfg(feature = "MEEmailAddress")]
        /// Recipient email addresses in the "Cc" address field of the message.
        #[unsafe(method(ccAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn ccAddresses(&self) -> Retained<NSArray<MEEmailAddress>>;

        #[cfg(feature = "MEEmailAddress")]
        /// Recipient email addresses in the "Bcc" address field of the message.
        #[unsafe(method(bccAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn bccAddresses(&self) -> Retained<NSArray<MEEmailAddress>>;

        #[cfg(feature = "MEEmailAddress")]
        /// Recipient email addresses in the "Reply-To" field of the message.
        #[unsafe(method(replyToAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn replyToAddresses(&self) -> Retained<NSArray<MEEmailAddress>>;

        #[cfg(feature = "MEEmailAddress")]
        /// An array containing all recipients of the message.
        #[unsafe(method(allRecipientAddresses))]
        #[unsafe(method_family = none)]
        pub unsafe fn allRecipientAddresses(&self) -> Retained<NSArray<MEEmailAddress>>;

        /// The date the mail message was sent. Optionally set by the by the sender.
        #[unsafe(method(dateSent))]
        #[unsafe(method_family = none)]
        pub unsafe fn dateSent(&self) -> Option<Retained<NSDate>>;

        /// The date the mail message was received. Only present if the message has been received.
        #[unsafe(method(dateReceived))]
        #[unsafe(method_family = none)]
        pub unsafe fn dateReceived(&self) -> Option<Retained<NSDate>>;

        /// The headers for the message. Might only be a subset if the full body has not been downloaded.
        #[unsafe(method(headers))]
        #[unsafe(method_family = none)]
        pub unsafe fn headers(&self)
            -> Option<Retained<NSDictionary<NSString, NSArray<NSString>>>>;

        /// The full raw RFC822 message data if it has been downloaded and the extension has permissions to access.
        #[unsafe(method(rawData))]
        #[unsafe(method_family = none)]
        pub unsafe fn rawData(&self) -> Option<Retained<NSData>>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}