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")]
50unsafe impl NSAccessibility for LPLinkView {}
51
52#[cfg(feature = "objc2-app-kit")]
53#[cfg(target_os = "macos")]
54unsafe impl NSAccessibilityElementProtocol for LPLinkView {}
55
56#[cfg(feature = "objc2-app-kit")]
57#[cfg(target_os = "macos")]
58unsafe impl NSAnimatablePropertyContainer for LPLinkView {}
59
60#[cfg(feature = "objc2-app-kit")]
61#[cfg(target_os = "macos")]
62unsafe impl NSAppearanceCustomization for LPLinkView {}
63
64#[cfg(feature = "objc2-app-kit")]
65#[cfg(target_os = "macos")]
66unsafe impl NSCoding for LPLinkView {}
67
68#[cfg(feature = "objc2-app-kit")]
69#[cfg(target_os = "macos")]
70unsafe impl NSDraggingDestination for LPLinkView {}
71
72#[cfg(feature = "objc2-app-kit")]
73#[cfg(target_os = "macos")]
74unsafe impl NSObjectProtocol for LPLinkView {}
75
76#[cfg(feature = "objc2-app-kit")]
77#[cfg(target_os = "macos")]
78unsafe impl NSUserInterfaceItemIdentification for LPLinkView {}
79
80#[cfg(feature = "objc2-app-kit")]
81#[cfg(target_os = "macos")]
82impl LPLinkView {
83    extern_methods!(
84        #[unsafe(method(initWithCoder:))]
85        #[unsafe(method_family = init)]
86        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
87
88        #[unsafe(method(encodeWithCoder:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn encodeWithCoder(&self, coder: &NSCoder);
91
92        /// Initializes a placeholder link view without metadata for a given URL.
93        #[unsafe(method(initWithURL:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
96
97        #[cfg(feature = "LPLinkMetadata")]
98        /// Initializes a link view with specified metadata.
99        #[unsafe(method(initWithMetadata:))]
100        #[unsafe(method_family = init)]
101        pub unsafe fn initWithMetadata(
102            this: Allocated<Self>,
103            metadata: &LPLinkMetadata,
104        ) -> Retained<Self>;
105
106        #[cfg(feature = "LPLinkMetadata")]
107        /// The metadata from which to generate a rich presentation.
108        ///
109        /// This can either be generated automatically from a URL by LPMetadataProvider,
110        /// or manually constructed with the desired data.
111        #[unsafe(method(metadata))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn metadata(&self) -> Retained<LPLinkMetadata>;
114
115        #[cfg(feature = "LPLinkMetadata")]
116        /// Setter for [`metadata`][Self::metadata].
117        #[unsafe(method(setMetadata:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setMetadata(&self, metadata: &LPLinkMetadata);
120    );
121}
122
123/// Methods declared on superclass `NSView`.
124#[cfg(feature = "objc2-app-kit")]
125#[cfg(target_os = "macos")]
126impl LPLinkView {
127    extern_methods!(
128        #[unsafe(method(initWithFrame:))]
129        #[unsafe(method_family = init)]
130        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
131    );
132}
133
134/// Methods declared on superclass `NSResponder`.
135#[cfg(feature = "objc2-app-kit")]
136#[cfg(target_os = "macos")]
137impl LPLinkView {
138    extern_methods!(
139        #[unsafe(method(init))]
140        #[unsafe(method_family = init)]
141        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
142    );
143}
144
145/// Methods declared on superclass `NSObject`.
146#[cfg(feature = "objc2-app-kit")]
147#[cfg(target_os = "macos")]
148impl LPLinkView {
149    extern_methods!(
150        #[unsafe(method(new))]
151        #[unsafe(method_family = new)]
152        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
153    );
154}