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