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
59extern_conformance!(
60    unsafe impl NSObjectProtocol for UIPrinter {}
61);
62
63impl UIPrinter {
64    extern_methods!(
65        /// Create a printer from its URL
66        ///
67        /// This method creates a new printer object from the printer's URL.
68        /// A UIPrinter object is returned even if the printer is not available
69        /// on the network.
70        #[unsafe(method(printerWithURL:))]
71        #[unsafe(method_family = none)]
72        pub fn printerWithURL(url: &NSURL, mtm: MainThreadMarker) -> Retained<UIPrinter>;
73
74        /// Return the URL of the printer.
75        ///
76        /// This method returns the full URL of the printer which can be
77        /// used in future calls to printerWithURL to access the same
78        /// printer.
79        #[unsafe(method(URL))]
80        #[unsafe(method_family = none)]
81        pub fn URL(&self) -> Retained<NSURL>;
82
83        /// Return a human-readable printer name.
84        ///
85        /// This method returns the printer name suitable for displaying in the UI.
86        #[unsafe(method(displayName))]
87        #[unsafe(method_family = none)]
88        pub fn displayName(&self) -> Retained<NSString>;
89
90        /// Return a human-readable location.
91        ///
92        /// This method returns the printer's location. This is human-readable text that
93        /// usually appears in the UI below the printer's name (such as "Front Office").
94        /// Returns nil if the printer doesn't have a location string.
95        /// This property's value is undefined until contactPrinter: has been called and
96        /// completed successfully.
97        #[unsafe(method(displayLocation))]
98        #[unsafe(method_family = none)]
99        pub fn displayLocation(&self) -> Option<Retained<NSString>>;
100
101        /// Returns the supported job types of this printer.
102        ///
103        /// This method returns a mask with all the UIPrinterJobTypes values that
104        /// the printer supports.
105        /// This property's value is undefined until contactPrinter: has been called and
106        /// completed successfully.
107        #[unsafe(method(supportedJobTypes))]
108        #[unsafe(method_family = none)]
109        pub fn supportedJobTypes(&self) -> UIPrinterJobTypes;
110
111        /// Return make (manufacturer) and model of the printer.
112        ///
113        /// This method returns the make and model of the printer, which
114        /// is usually the manufacturer, model, and model number.
115        /// This property's value is undefined until contactPrinter: has been called and
116        /// completed successfully.
117        #[unsafe(method(makeAndModel))]
118        #[unsafe(method_family = none)]
119        pub fn makeAndModel(&self) -> Option<Retained<NSString>>;
120
121        /// Return whether this printer supports color printing.
122        ///
123        /// This method returns YES if the printer supports full color printing, NO
124        /// otherwise.
125        /// This property's value is undefined until contactPrinter: has been called and
126        /// completed successfully.
127        #[unsafe(method(supportsColor))]
128        #[unsafe(method_family = none)]
129        pub fn supportsColor(&self) -> bool;
130
131        /// Return whether this printer supports duplex (double-sided) printing.
132        ///
133        /// This method returns YES if the printer supports duplex (double-sided)
134        /// printing, NO otherwise.
135        /// This property's value is undefined until contactPrinter: has been called and
136        /// completed successfully.
137        #[unsafe(method(supportsDuplex))]
138        #[unsafe(method_family = none)]
139        pub fn supportsDuplex(&self) -> bool;
140
141        #[cfg(feature = "block2")]
142        /// Check if printer is reachable, and update printer information.
143        ///
144        /// This method checks to see if this printer is available on the network,
145        /// and sets the displayName, displayLocation, supportedJobTypes, makeAndModel,
146        /// supportsColor, and supportsDuplex for the printer.
147        /// The operation can take up to 30 seconds.
148        #[unsafe(method(contactPrinter:))]
149        #[unsafe(method_family = none)]
150        pub fn contactPrinter(&self, completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>);
151    );
152}
153
154/// Methods declared on superclass `NSObject`.
155impl UIPrinter {
156    extern_methods!(
157        #[unsafe(method(init))]
158        #[unsafe(method_family = init)]
159        pub fn init(this: Allocated<Self>) -> Retained<Self>;
160
161        #[unsafe(method(new))]
162        #[unsafe(method_family = new)]
163        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
164    );
165}