objc2_web_kit/generated/
NSAttributedString.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern "C" {
14    /// Indicates which local files WebKit can access when loading content.
15    ///
16    /// If NSReadAccessURLDocumentOption references a single file, only that file may be
17    /// loaded by WebKit. If NSReadAccessURLDocumentOption references a directory, files inside that
18    /// directory may be loaded by WebKit.
19    ///
20    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/nsreadaccessurldocumentoption?language=objc)
21    #[cfg(feature = "objc2-app-kit")]
22    #[cfg(target_os = "macos")]
23    pub static NSReadAccessURLDocumentOption: &'static NSAttributedStringDocumentReadingOptionKey;
24}
25
26/// Type definition for the completion handler block used to get asynchronous attributed strings.
27///
28/// The completion handler block is passed the attributed string result along with any
29/// document-level attributes, like NSBackgroundColorDocumentAttribute, or an error. An implementation
30/// of this block type must expect to be called asynchronously when passed to HTML loading methods.
31///
32/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/nsattributedstringcompletionhandler?language=objc)
33#[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
34#[cfg(target_os = "macos")]
35pub type NSAttributedStringCompletionHandler = *mut block2::Block<
36    dyn Fn(
37        *mut NSAttributedString,
38        *mut NSDictionary<NSAttributedStringDocumentAttributeKey, AnyObject>,
39        *mut NSError,
40    ),
41>;
42
43mod private_NSAttributedStringWebKitAdditions {
44    pub trait Sealed {}
45}
46
47/// Category on [`NSAttributedString`].
48/// Extension of
49///
50/// ```text
51///  //apple_ref/occ/NSAttributedString NSAttributedString
52/// ```
53///
54/// to
55/// create attributed strings from HTML content using WebKit.
56pub unsafe trait NSAttributedStringWebKitAdditions:
57    ClassType + Sized + private_NSAttributedStringWebKitAdditions::Sealed
58{
59    extern_methods!(
60        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
61        #[cfg(target_os = "macos")]
62        /// Loads an HTML URL request and converts the contents into an attributed string.
63        ///
64        /// Parameter `request`: The request specifying the URL to load.
65        ///
66        /// Parameter `options`: Document attributes for interpreting the document contents.
67        /// NSTextSizeMultiplierDocumentOption and NSTimeoutDocumentOption are supported option keys.
68        ///
69        /// Parameter `completionHandler`: A block to invoke when the operation completes or fails.
70        ///
71        /// The completionHandler is passed the attributed string result along with any
72        /// document-level attributes, or an error.
73        #[unsafe(method(loadFromHTMLWithRequest:options:completionHandler:))]
74        #[unsafe(method_family = none)]
75        unsafe fn loadFromHTMLWithRequest_options_completionHandler(
76            request: &NSURLRequest,
77            options: &NSDictionary<NSAttributedStringDocumentReadingOptionKey, AnyObject>,
78            completion_handler: NSAttributedStringCompletionHandler,
79        );
80
81        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
82        #[cfg(target_os = "macos")]
83        /// Converts a local HTML file into an attributed string.
84        ///
85        /// Parameter `fileURL`: The file URL to load.
86        ///
87        /// Parameter `options`: Document attributes for interpreting the document contents.
88        /// NSTextSizeMultiplierDocumentOption, NSTimeoutDocumentOption and NSReadAccessURLDocumentOption
89        /// are supported option keys.
90        ///
91        /// Parameter `completionHandler`: A block to invoke when the operation completes or fails.
92        ///
93        /// The completionHandler is passed the attributed string result along with any
94        /// document-level attributes, or an error. If NSReadAccessURLDocumentOption references a single file,
95        /// only that file may be loaded by WebKit. If NSReadAccessURLDocumentOption references a directory,
96        /// files inside that directory may be loaded by WebKit.
97        #[unsafe(method(loadFromHTMLWithFileURL:options:completionHandler:))]
98        #[unsafe(method_family = none)]
99        unsafe fn loadFromHTMLWithFileURL_options_completionHandler(
100            file_url: &NSURL,
101            options: &NSDictionary<NSAttributedStringDocumentReadingOptionKey, AnyObject>,
102            completion_handler: NSAttributedStringCompletionHandler,
103        );
104
105        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
106        #[cfg(target_os = "macos")]
107        /// Converts an HTML string into an attributed string.
108        ///
109        /// Parameter `string`: The HTML string to use as the contents.
110        ///
111        /// Parameter `options`: Document attributes for interpreting the document contents.
112        /// NSTextSizeMultiplierDocumentOption, NSTimeoutDocumentOption and NSBaseURLDocumentOption
113        /// are supported option keys.
114        ///
115        /// Parameter `completionHandler`: A block to invoke when the operation completes or fails.
116        ///
117        /// The completionHandler is passed the attributed string result along with any
118        /// document-level attributes, or an error. NSBaseURLDocumentOption is used to resolve relative URLs
119        /// within the document.
120        #[unsafe(method(loadFromHTMLWithString:options:completionHandler:))]
121        #[unsafe(method_family = none)]
122        unsafe fn loadFromHTMLWithString_options_completionHandler(
123            string: &NSString,
124            options: &NSDictionary<NSAttributedStringDocumentReadingOptionKey, AnyObject>,
125            completion_handler: NSAttributedStringCompletionHandler,
126        );
127
128        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
129        #[cfg(target_os = "macos")]
130        /// Converts HTML data into an attributed string.
131        ///
132        /// Parameter `data`: The HTML data to use as the contents.
133        ///
134        /// Parameter `options`: Document attributes for interpreting the document contents.
135        /// NSTextSizeMultiplierDocumentOption, NSTimeoutDocumentOption, NSTextEncodingNameDocumentOption,
136        /// and NSCharacterEncodingDocumentOption are supported option keys.
137        ///
138        /// Parameter `completionHandler`: A block to invoke when the operation completes or fails.
139        ///
140        /// The completionHandler is passed the attributed string result along with any
141        /// document-level attributes, or an error. If neither NSTextEncodingNameDocumentOption nor
142        /// NSCharacterEncodingDocumentOption is supplied, a best-guess encoding is used.
143        #[unsafe(method(loadFromHTMLWithData:options:completionHandler:))]
144        #[unsafe(method_family = none)]
145        unsafe fn loadFromHTMLWithData_options_completionHandler(
146            data: &NSData,
147            options: &NSDictionary<NSAttributedStringDocumentReadingOptionKey, AnyObject>,
148            completion_handler: NSAttributedStringCompletionHandler,
149        );
150    );
151}
152
153impl private_NSAttributedStringWebKitAdditions::Sealed for NSAttributedString {}
154unsafe impl NSAttributedStringWebKitAdditions for NSAttributedString {}