objc2_link_presentation/generated/LPLinkMetadata.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// An object that contains metadata about a URL.
12 ///
13 /// Use ``LPLinkMetadata`` to store the metadata about a URL, including its
14 /// title, icon, images and video.
15 ///
16 /// Fetch metadata using ``LPMetadataProvider``. For remote URLs, cache the
17 /// metadata locally to avoid the data and performance cost of fetching it from
18 /// the internet every time you present it. ``LPLinkMetadata`` is serializable
19 /// with
20 /// <doc
21 /// ://com.apple.documentation/documentation/foundation/nssecurecoding>.
22 ///
23 /// For local file URLs, the
24 /// <doc
25 /// ://com.apple.documentation/documentation/quicklookthumbnailing> API
26 /// retrieves a representative thumbnail for the file, if possible.
27 ///
28 /// ## Provide custom metadata
29 ///
30 /// Say your app already has a database of links, with titles and images that
31 /// weren’t fetched by ``LPMetadataProvider``. You don’t have to fetch new
32 /// metadata from the internet in order to accelerate the share sheet or to
33 /// present a rich link. Instead, you can fill in the fields of
34 /// ``LPLinkMetadata`` yourself.
35 ///
36 /// Create an ``LPLinkMetadata`` object, and fill in at least the
37 /// ``LPLinkMetadata/originalURL`` and ``LPLinkMetadata/URL`` fields, plus
38 /// whatever additional information you have.
39 ///
40 /// ```swift
41 /// func activityViewControllerLinkMetadata(_: UIActivityViewController) -> LPLinkMetadata? {
42 /// let metadata = LPLinkMetadata()
43 /// metadata.originalURL = URL(string: "https://www.example.com/apple-pie")
44 /// metadata.url = metadata.originalURL
45 /// metadata.title = "The Greatest Apple Pie In The World"
46 /// metadata.imageProvider = NSItemProvider.init(contentsOf:
47 /// Bundle.main.url(forResource: "apple-pie", withExtension: "jpg"))
48 /// return metadata
49 /// }
50 /// ```
51 ///
52 /// ## Accelerate the share sheet preview
53 ///
54 /// For existing apps that share URLs, the share sheet automatically presents a
55 /// preview of the link. The preview first shows a placeholder link icon
56 /// alongside the base URL while fetching the link’s metadata over the network.
57 /// The preview updates once the link’s icon and title become available.
58 ///
59 /// If you already have an ``LPLinkMetadata`` object for a URL, pass it to the
60 /// share sheet to present the preview instantly, without fetching data over the
61 /// network. In your implementation of
62 /// <doc
63 /// ://com.apple.documentation/documentation/uikit/uiactivityitemsource/3144571-activityviewcontrollerlinkmetada>,
64 /// return the metadata object.
65 ///
66 /// ```swift
67 /// func activityViewControllerLinkMetadata(_:
68 /// UIActivityViewController) -> LPLinkMetadata? {
69 /// return self.metadata
70 /// }
71 /// ```
72 ///
73 /// If the user chooses to share to Messages, the same metadata passes directly
74 /// through, providing a smooth and seamless experience with no unnecessary
75 /// loading.
76 ///
77 /// See also [Apple's documentation](https://developer.apple.com/documentation/linkpresentation/lplinkmetadata?language=objc)
78 #[unsafe(super(NSObject))]
79 #[derive(Debug, PartialEq, Eq, Hash)]
80 pub struct LPLinkMetadata;
81);
82
83unsafe impl NSCoding for LPLinkMetadata {}
84
85unsafe impl NSCopying for LPLinkMetadata {}
86
87unsafe impl CopyingHelper for LPLinkMetadata {
88 type Result = Self;
89}
90
91unsafe impl NSObjectProtocol for LPLinkMetadata {}
92
93unsafe impl NSSecureCoding for LPLinkMetadata {}
94
95impl LPLinkMetadata {
96 extern_methods!(
97 /// The original URL of the metadata request.
98 #[unsafe(method(originalURL))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn originalURL(&self) -> Option<Retained<NSURL>>;
101
102 /// Setter for [`originalURL`][Self::originalURL].
103 #[unsafe(method(setOriginalURL:))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn setOriginalURL(&self, original_url: Option<&NSURL>);
106
107 /// The URL that returned the metadata, taking server-side redirects into
108 /// account.
109 ///
110 /// The URL that returns the metadata may differ from the
111 /// ``LPLinkMetadata/originalURL`` to which you sent the metadata request. This
112 /// can happen if the server redirects the request, for example, when a resource
113 /// has moved, or when the original URL is a domain alias.
114 #[unsafe(method(URL))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
117
118 /// Setter for [`URL`][Self::URL].
119 #[unsafe(method(setURL:))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn setURL(&self, url: Option<&NSURL>);
122
123 /// A representative title for the URL.
124 #[unsafe(method(title))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
127
128 /// Setter for [`title`][Self::title].
129 #[unsafe(method(setTitle:))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn setTitle(&self, title: Option<&NSString>);
132
133 /// An object that retrieves data corresponding to a representative icon for the
134 /// URL.
135 #[unsafe(method(iconProvider))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn iconProvider(&self) -> Option<Retained<NSItemProvider>>;
138
139 /// Setter for [`iconProvider`][Self::iconProvider].
140 #[unsafe(method(setIconProvider:))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn setIconProvider(&self, icon_provider: Option<&NSItemProvider>);
143
144 /// An object that retrieves data corresponding to a representative image for
145 /// the URL.
146 #[unsafe(method(imageProvider))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn imageProvider(&self) -> Option<Retained<NSItemProvider>>;
149
150 /// Setter for [`imageProvider`][Self::imageProvider].
151 #[unsafe(method(setImageProvider:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn setImageProvider(&self, image_provider: Option<&NSItemProvider>);
154
155 /// An object that retrieves data corresponding to a representative video for
156 /// the URL.
157 ///
158 /// The item provider returns a video that
159 /// <doc
160 /// ://com.apple.documentation/documentation/avfoundation> can play.
161 #[unsafe(method(videoProvider))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn videoProvider(&self) -> Option<Retained<NSItemProvider>>;
164
165 /// Setter for [`videoProvider`][Self::videoProvider].
166 #[unsafe(method(setVideoProvider:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn setVideoProvider(&self, video_provider: Option<&NSItemProvider>);
169
170 /// A remote URL corresponding to a representative video for the URL.
171 ///
172 /// This may reference a remote video file that
173 /// <doc
174 /// ://com.apple.documentation/documentation/avfoundation> can stream,
175 /// or a YouTube video URL.
176 #[unsafe(method(remoteVideoURL))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn remoteVideoURL(&self) -> Option<Retained<NSURL>>;
179
180 /// Setter for [`remoteVideoURL`][Self::remoteVideoURL].
181 #[unsafe(method(setRemoteVideoURL:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn setRemoteVideoURL(&self, remote_video_url: Option<&NSURL>);
184 );
185}
186
187/// Methods declared on superclass `NSObject`.
188impl LPLinkMetadata {
189 extern_methods!(
190 #[unsafe(method(init))]
191 #[unsafe(method_family = init)]
192 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
193
194 #[unsafe(method(new))]
195 #[unsafe(method_family = new)]
196 pub unsafe fn new() -> Retained<Self>;
197 );
198}