objc2_ui_kit/generated/UIPrinter.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
10/// Job types supported by a printer.
11///
12/// This enumeration provides the abstract job types
13/// reported by the UIPrinter supportedJobTypes method.
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiprinterjobtypes?language=objc)
16// NS_OPTIONS
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIPrinterJobTypes(pub NSInteger);
20bitflags::bitflags! {
21 impl UIPrinterJobTypes: NSInteger {
22 #[doc(alias = "UIPrinterJobTypeUnknown")]
23 const Unknown = 0;
24 #[doc(alias = "UIPrinterJobTypeDocument")]
25 const Document = 1<<0;
26 #[doc(alias = "UIPrinterJobTypeEnvelope")]
27 const Envelope = 1<<1;
28 #[doc(alias = "UIPrinterJobTypeLabel")]
29 const Label = 1<<2;
30 #[doc(alias = "UIPrinterJobTypePhoto")]
31 const Photo = 1<<3;
32 #[doc(alias = "UIPrinterJobTypeReceipt")]
33 const Receipt = 1<<4;
34 #[doc(alias = "UIPrinterJobTypeRoll")]
35 const Roll = 1<<5;
36 #[doc(alias = "UIPrinterJobTypeLargeFormat")]
37 const LargeFormat = 1<<6;
38 #[doc(alias = "UIPrinterJobTypePostcard")]
39 const Postcard = 1<<7;
40 }
41}
42
43unsafe impl Encode for UIPrinterJobTypes {
44 const ENCODING: Encoding = NSInteger::ENCODING;
45}
46
47unsafe impl RefEncode for UIPrinterJobTypes {
48 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
49}
50
51extern_class!(
52 /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiprinter?language=objc)
53 #[unsafe(super(NSObject))]
54 #[thread_kind = MainThreadOnly]
55 #[derive(Debug, PartialEq, Eq, Hash)]
56 pub struct UIPrinter;
57);
58
59unsafe impl NSObjectProtocol for UIPrinter {}
60
61impl UIPrinter {
62 extern_methods!(
63 /// Create a printer from its URL
64 ///
65 /// This method creates a new printer object from the printer's URL.
66 /// A UIPrinter object is returned even if the printer is not available
67 /// on the network.
68 #[unsafe(method(printerWithURL:))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn printerWithURL(url: &NSURL, mtm: MainThreadMarker) -> Retained<UIPrinter>;
71
72 /// Return the URL of the printer.
73 ///
74 /// This method returns the full URL of the printer which can be
75 /// used in future calls to printerWithURL to access the same
76 /// printer.
77 #[unsafe(method(URL))]
78 #[unsafe(method_family = none)]
79 pub unsafe fn URL(&self) -> Retained<NSURL>;
80
81 /// Return a human-readable printer name.
82 ///
83 /// This method returns the printer name suitable for displaying in the UI.
84 #[unsafe(method(displayName))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn displayName(&self) -> Retained<NSString>;
87
88 /// Return a human-readable location.
89 ///
90 /// This method returns the printer's location. This is human-readable text that
91 /// usually appears in the UI below the printer's name (such as "Front Office").
92 /// Returns nil if the printer doesn't have a location string.
93 /// This property's value is undefined until contactPrinter: has been called and
94 /// completed successfully.
95 #[unsafe(method(displayLocation))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn displayLocation(&self) -> Option<Retained<NSString>>;
98
99 /// Returns the supported job types of this printer.
100 ///
101 /// This method returns a mask with all the UIPrinterJobTypes values that
102 /// the printer supports.
103 /// This property's value is undefined until contactPrinter: has been called and
104 /// completed successfully.
105 #[unsafe(method(supportedJobTypes))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn supportedJobTypes(&self) -> UIPrinterJobTypes;
108
109 /// Return make (manufacturer) and model of the printer.
110 ///
111 /// This method returns the make and model of the printer, which
112 /// is usually the manufacturer, model, and model number.
113 /// This property's value is undefined until contactPrinter: has been called and
114 /// completed successfully.
115 #[unsafe(method(makeAndModel))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn makeAndModel(&self) -> Option<Retained<NSString>>;
118
119 /// Return whether this printer supports color printing.
120 ///
121 /// This method returns YES if the printer supports full color printing, NO
122 /// otherwise.
123 /// This property's value is undefined until contactPrinter: has been called and
124 /// completed successfully.
125 #[unsafe(method(supportsColor))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn supportsColor(&self) -> bool;
128
129 /// Return whether this printer supports duplex (double-sided) printing.
130 ///
131 /// This method returns YES if the printer supports duplex (double-sided)
132 /// printing, NO otherwise.
133 /// This property's value is undefined until contactPrinter: has been called and
134 /// completed successfully.
135 #[unsafe(method(supportsDuplex))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn supportsDuplex(&self) -> bool;
138
139 #[cfg(feature = "block2")]
140 /// Check if printer is reachable, and update printer information.
141 ///
142 /// This method checks to see if this printer is available on the network,
143 /// and sets the displayName, displayLocation, supportedJobTypes, makeAndModel,
144 /// supportsColor, and supportsDuplex for the printer.
145 /// The operation can take up to 30 seconds.
146 #[unsafe(method(contactPrinter:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn contactPrinter(
149 &self,
150 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
151 );
152 );
153}
154
155/// Methods declared on superclass `NSObject`.
156impl UIPrinter {
157 extern_methods!(
158 #[unsafe(method(init))]
159 #[unsafe(method_family = init)]
160 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
161
162 #[unsafe(method(new))]
163 #[unsafe(method_family = new)]
164 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
165 );
166}