objc2_link_presentation/generated/
LPLinkView.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_class!(
14    /// A rich visual representation of a link.
15    ///
16    /// ``LPLinkView`` presents a link based on its available metadata. Use it to
17    /// show a link’s title and icon, associated images, inline audio, video
18    /// playback, and maps in a familiar and consistent style.
19    ///
20    /// ## Present a rich link
21    ///
22    /// To present a rich link in your app, create an ``LPLinkView``, passing an
23    /// ``LPLinkMetadata`` instance into its initializer. Then add the
24    /// ``LPLinkView`` to your view.
25    ///
26    /// For example, to present links in a table view, add an ``LPLinkView``
27    /// instance as a subview when populating each cell.
28    ///
29    /// ```swift
30    /// let linkView = LPLinkView(metadata: metadata)
31    /// cell.contentView.addSubview(linkView)
32    /// linkView.sizeToFit()
33    /// ```
34    ///
35    /// ``LPLinkView`` has an intrinsic size, but it also responds to
36    /// <doc
37    /// ://com.apple.documentation/documentation/uikit/uiview/1622630-sizetofit>
38    /// to present a layout at any size.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/linkpresentation/lplinkview?language=objc)
41    #[unsafe(super(NSView, NSResponder, NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    #[cfg(feature = "objc2-app-kit")]
44    #[cfg(target_os = "macos")]
45    pub struct LPLinkView;
46);
47
48#[cfg(feature = "objc2-app-kit")]
49#[cfg(target_os = "macos")]
50extern_conformance!(
51    unsafe impl NSAccessibility for LPLinkView {}
52);
53
54#[cfg(feature = "objc2-app-kit")]
55#[cfg(target_os = "macos")]
56extern_conformance!(
57    unsafe impl NSAccessibilityElementProtocol for LPLinkView {}
58);
59
60#[cfg(feature = "objc2-app-kit")]
61#[cfg(target_os = "macos")]
62extern_conformance!(
63    unsafe impl NSAnimatablePropertyContainer for LPLinkView {}
64);
65
66#[cfg(feature = "objc2-app-kit")]
67#[cfg(target_os = "macos")]
68extern_conformance!(
69    unsafe impl NSAppearanceCustomization for LPLinkView {}
70);
71
72#[cfg(feature = "objc2-app-kit")]
73#[cfg(target_os = "macos")]
74extern_conformance!(
75    unsafe impl NSCoding for LPLinkView {}
76);
77
78#[cfg(feature = "objc2-app-kit")]
79#[cfg(target_os = "macos")]
80extern_conformance!(
81    unsafe impl NSDraggingDestination for LPLinkView {}
82);
83
84#[cfg(feature = "objc2-app-kit")]
85#[cfg(target_os = "macos")]
86extern_conformance!(
87    unsafe impl NSObjectProtocol for LPLinkView {}
88);
89
90#[cfg(feature = "objc2-app-kit")]
91#[cfg(target_os = "macos")]
92extern_conformance!(
93    unsafe impl NSUserInterfaceItemIdentification for LPLinkView {}
94);
95
96#[cfg(feature = "objc2-app-kit")]
97#[cfg(target_os = "macos")]
98impl LPLinkView {
99    extern_methods!(
100        /// # Safety
101        ///
102        /// `coder` possibly has further requirements.
103        #[unsafe(method(initWithCoder:))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
106
107        /// # Safety
108        ///
109        /// `coder` possibly has further requirements.
110        #[unsafe(method(encodeWithCoder:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
113
114        /// Initializes a placeholder link view without metadata for a given URL.
115        #[unsafe(method(initWithURL:))]
116        #[unsafe(method_family = init)]
117        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
118
119        #[cfg(feature = "LPLinkMetadata")]
120        /// Initializes a link view with specified metadata.
121        #[unsafe(method(initWithMetadata:))]
122        #[unsafe(method_family = init)]
123        pub unsafe fn initWithMetadata(
124            this: Allocated<Self>,
125            metadata: &LPLinkMetadata,
126        ) -> Retained<Self>;
127
128        #[cfg(feature = "LPLinkMetadata")]
129        /// The metadata from which to generate a rich presentation.
130        ///
131        /// This can either be generated automatically from a URL by LPMetadataProvider,
132        /// or manually constructed with the desired data.
133        #[unsafe(method(metadata))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn metadata(&self) -> Retained<LPLinkMetadata>;
136
137        #[cfg(feature = "LPLinkMetadata")]
138        /// Setter for [`metadata`][Self::metadata].
139        ///
140        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
141        #[unsafe(method(setMetadata:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn setMetadata(&self, metadata: &LPLinkMetadata);
144    );
145}
146
147/// Methods declared on superclass `NSView`.
148#[cfg(feature = "objc2-app-kit")]
149#[cfg(target_os = "macos")]
150impl LPLinkView {
151    extern_methods!(
152        #[unsafe(method(initWithFrame:))]
153        #[unsafe(method_family = init)]
154        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
155    );
156}
157
158/// Methods declared on superclass `NSResponder`.
159#[cfg(feature = "objc2-app-kit")]
160#[cfg(target_os = "macos")]
161impl LPLinkView {
162    extern_methods!(
163        #[unsafe(method(init))]
164        #[unsafe(method_family = init)]
165        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166    );
167}
168
169/// Methods declared on superclass `NSObject`.
170#[cfg(feature = "objc2-app-kit")]
171#[cfg(target_os = "macos")]
172impl LPLinkView {
173    extern_methods!(
174        #[unsafe(method(new))]
175        #[unsafe(method_family = new)]
176        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
177    );
178}