objc2-intents 0.3.2

Bindings to the Intents 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!(
    /// An object that describes a piece of data and its associated name and uniform type identifier.
    /// This data can either be stored in a file on disk, or in memory.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/intents/infile?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct INFile;
);

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

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

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

impl INFile {
    extern_methods!(
        #[unsafe(method(fileWithData:filename:typeIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fileWithData_filename_typeIdentifier(
            data: &NSData,
            filename: &NSString,
            type_identifier: Option<&NSString>,
        ) -> Retained<INFile>;

        #[unsafe(method(fileWithFileURL:filename:typeIdentifier:))]
        #[unsafe(method_family = none)]
        pub unsafe fn fileWithFileURL_filename_typeIdentifier(
            file_url: &NSURL,
            filename: Option<&NSString>,
            type_identifier: Option<&NSString>,
        ) -> Retained<INFile>;

        /// The contents of the file.
        /// If the file was created with a URL, accessing this property will memory map the file contents.
        #[unsafe(method(data))]
        #[unsafe(method_family = none)]
        pub unsafe fn data(&self) -> Retained<NSData>;

        /// The human-readable name of the file, which will be displayed to the user.
        #[unsafe(method(filename))]
        #[unsafe(method_family = none)]
        pub unsafe fn filename(&self) -> Retained<NSString>;

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

        /// The uniform type identifier of the file. (i.e. "public.json", "public.png", or any custom type)
        /// More information about uniform type identifiers can be found in
        /// <CoreServices
        /// /UTCoreTypes.h>
        #[unsafe(method(typeIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn typeIdentifier(&self) -> Option<Retained<NSString>>;

        /// URL to the file on disk, if any.
        /// If the file isn't stored on disk, access the contents using the `data` property.
        ///
        /// If the file was created elsewhere on the system, make sure to surround access to file contents
        /// with `-[NSURL startAccessingSecurityScopedResource]` and `-[NSURL stopAccessingSecurityScopedResource]`.
        #[unsafe(method(fileURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn fileURL(&self) -> Option<Retained<NSURL>>;

        /// Indicates whether the file should be automatically deleted from disk when the Shortcut is done running. `false` by default.
        #[unsafe(method(removedOnCompletion))]
        #[unsafe(method_family = none)]
        pub unsafe fn removedOnCompletion(&self) -> bool;

        /// Setter for [`removedOnCompletion`][Self::removedOnCompletion].
        #[unsafe(method(setRemovedOnCompletion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRemovedOnCompletion(&self, removed_on_completion: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl INFile {
    extern_methods!(
        #[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>;
    );
}