#[repr(C)]pub struct ICScannerFunctionalUnit { /* private fields */ }
ICScannerFunctionalUnits
only.Expand description
ICScannerFunctionalUnit is an abstract class that represents a scanner functiona unit. ImageCaptureCore defines three concrete subclasses of ICScannerFunctionalUnit: ICScannerFunctionalUnitFlatbed, ICScannerFunctionalUnitPositiveTransparency, ICScannerFunctionalUnitNegativeTransparency and ICScannerFunctionalUnitDocumentFeeder. ICScannerDevice creates instances of these concrete subclasses.
See also Apple’s documentation
Implementations§
Source§impl ICScannerFunctionalUnit
impl ICScannerFunctionalUnit
Sourcepub unsafe fn type(&self) -> ICScannerFunctionalUnitType
pub unsafe fn type(&self) -> ICScannerFunctionalUnitType
Functional unit type.
Sourcepub unsafe fn pixelDataType(&self) -> ICScannerPixelDataType
pub unsafe fn pixelDataType(&self) -> ICScannerPixelDataType
The pixel data type.
Sourcepub unsafe fn setPixelDataType(&self, pixel_data_type: ICScannerPixelDataType)
pub unsafe fn setPixelDataType(&self, pixel_data_type: ICScannerPixelDataType)
Setter for pixelDataType
.
Sourcepub unsafe fn supportedBitDepths(&self) -> Retained<NSIndexSet>
pub unsafe fn supportedBitDepths(&self) -> Retained<NSIndexSet>
Supported bit depths. The values in this set are valid values defined by ICScannerBitDepth.
Sourcepub unsafe fn bitDepth(&self) -> ICScannerBitDepth
pub unsafe fn bitDepth(&self) -> ICScannerBitDepth
The bit depth to use when performing the final scan. This will always be one of the supported bit depths.
Sourcepub unsafe fn setBitDepth(&self, bit_depth: ICScannerBitDepth)
pub unsafe fn setBitDepth(&self, bit_depth: ICScannerBitDepth)
Setter for bitDepth
.
Sourcepub unsafe fn supportedMeasurementUnits(&self) -> Retained<NSIndexSet>
pub unsafe fn supportedMeasurementUnits(&self) -> Retained<NSIndexSet>
Supported measurement units. The values in this set are valid values defined by ICScannerMeasurementUnit.
Sourcepub unsafe fn measurementUnit(&self) -> ICScannerMeasurementUnit
pub unsafe fn measurementUnit(&self) -> ICScannerMeasurementUnit
Current measurement unit. This will always be one of the supported measurement units.
Sourcepub unsafe fn setMeasurementUnit(
&self,
measurement_unit: ICScannerMeasurementUnit,
)
pub unsafe fn setMeasurementUnit( &self, measurement_unit: ICScannerMeasurementUnit, )
Setter for measurementUnit
.
Sourcepub unsafe fn supportedResolutions(&self) -> Retained<NSIndexSet>
pub unsafe fn supportedResolutions(&self) -> Retained<NSIndexSet>
Supported scan resolutions in DPI.
Sourcepub unsafe fn preferredResolutions(&self) -> Retained<NSIndexSet>
pub unsafe fn preferredResolutions(&self) -> Retained<NSIndexSet>
Preferred scan resolutions in DPI.
Sourcepub unsafe fn resolution(&self) -> NSUInteger
pub unsafe fn resolution(&self) -> NSUInteger
Current scan resolution. This will always be one of the supported resolution values.
Sourcepub unsafe fn setResolution(&self, resolution: NSUInteger)
pub unsafe fn setResolution(&self, resolution: NSUInteger)
Setter for resolution
.
Sourcepub unsafe fn nativeXResolution(&self) -> NSUInteger
pub unsafe fn nativeXResolution(&self) -> NSUInteger
Optical resolution along the X axis.
Sourcepub unsafe fn nativeYResolution(&self) -> NSUInteger
pub unsafe fn nativeYResolution(&self) -> NSUInteger
Optical resolution along the Y axis.
Sourcepub unsafe fn supportedScaleFactors(&self) -> Retained<NSIndexSet>
pub unsafe fn supportedScaleFactors(&self) -> Retained<NSIndexSet>
Supported scale factors in percentage.
Sourcepub unsafe fn preferredScaleFactors(&self) -> Retained<NSIndexSet>
pub unsafe fn preferredScaleFactors(&self) -> Retained<NSIndexSet>
Preferred scale factors in percentage.
Sourcepub unsafe fn scaleFactor(&self) -> NSUInteger
pub unsafe fn scaleFactor(&self) -> NSUInteger
Current scale factor. This will always be one of the supported scale factor values.
Sourcepub unsafe fn setScaleFactor(&self, scale_factor: NSUInteger)
pub unsafe fn setScaleFactor(&self, scale_factor: NSUInteger)
Setter for scaleFactor
.
Sourcepub unsafe fn templates(&self) -> Retained<NSArray<ICScannerFeatureTemplate>>
pub unsafe fn templates(&self) -> Retained<NSArray<ICScannerFeatureTemplate>>
An array of objects of type ICScannerFeatureTemplate.
Sourcepub unsafe fn vendorFeatures(
&self,
) -> Option<Retained<NSArray<ICScannerFeature>>>
pub unsafe fn vendorFeatures( &self, ) -> Option<Retained<NSArray<ICScannerFeature>>>
An array of objects of type ICScannerFeature.
Sourcepub unsafe fn physicalSize(&self) -> NSSize
pub unsafe fn physicalSize(&self) -> NSSize
Physical size of the scan area in current measurement unit.
Sourcepub unsafe fn scanArea(&self) -> NSRect
pub unsafe fn scanArea(&self) -> NSRect
This property along with scanAreaOrientation describes the area to be scanned.
Sourcepub unsafe fn setScanArea(&self, scan_area: NSRect)
pub unsafe fn setScanArea(&self, scan_area: NSRect)
Setter for scanArea
.
Sourcepub unsafe fn scanAreaOrientation(&self) -> ICEXIFOrientationType
Available on crate feature ImageCaptureConstants
only.
pub unsafe fn scanAreaOrientation(&self) -> ICEXIFOrientationType
ImageCaptureConstants
only.Desired orientation of the scan area. This property along with scanArea describes the area to be scanned.
This property is set to ICEXIFOrientation1 initially. This property is not used by the ICScannerFunctionalUnitDocumentFeeder subclass.
Sourcepub unsafe fn setScanAreaOrientation(
&self,
scan_area_orientation: ICEXIFOrientationType,
)
Available on crate feature ImageCaptureConstants
only.
pub unsafe fn setScanAreaOrientation( &self, scan_area_orientation: ICEXIFOrientationType, )
ImageCaptureConstants
only.Setter for scanAreaOrientation
.
Sourcepub unsafe fn acceptsThresholdForBlackAndWhiteScanning(&self) -> bool
pub unsafe fn acceptsThresholdForBlackAndWhiteScanning(&self) -> bool
Indicates if this functional unit accepts threshold value to be used when performing a scan in black & white.
Sourcepub unsafe fn usesThresholdForBlackAndWhiteScanning(&self) -> bool
pub unsafe fn usesThresholdForBlackAndWhiteScanning(&self) -> bool
Indicates if this functional unit uses threshold value to be used when performing a scan in black & white.
Sourcepub unsafe fn setUsesThresholdForBlackAndWhiteScanning(
&self,
uses_threshold_for_black_and_white_scanning: bool,
)
pub unsafe fn setUsesThresholdForBlackAndWhiteScanning( &self, uses_threshold_for_black_and_white_scanning: bool, )
Setter for usesThresholdForBlackAndWhiteScanning
.
Sourcepub unsafe fn defaultThresholdForBlackAndWhiteScanning(&self) -> c_uchar
pub unsafe fn defaultThresholdForBlackAndWhiteScanning(&self) -> c_uchar
Default threshold value used when performing a scan in black & white. This value is from 0 to 255.
Sourcepub unsafe fn thresholdForBlackAndWhiteScanning(&self) -> c_uchar
pub unsafe fn thresholdForBlackAndWhiteScanning(&self) -> c_uchar
Threshold value to be used when performing a scan in black & white. This value should be from 0 to 255.
Sourcepub unsafe fn setThresholdForBlackAndWhiteScanning(
&self,
threshold_for_black_and_white_scanning: c_uchar,
)
pub unsafe fn setThresholdForBlackAndWhiteScanning( &self, threshold_for_black_and_white_scanning: c_uchar, )
Setter for thresholdForBlackAndWhiteScanning
.
Sourcepub unsafe fn state(&self) -> ICScannerFunctionalUnitState
pub unsafe fn state(&self) -> ICScannerFunctionalUnitState
Indicates the current state of the functional unit.
Sourcepub unsafe fn scanInProgress(&self) -> bool
pub unsafe fn scanInProgress(&self) -> bool
Indicates if a scan is in progress.
Sourcepub unsafe fn scanProgressPercentDone(&self) -> CGFloat
Available on crate feature objc2-core-foundation
only.
pub unsafe fn scanProgressPercentDone(&self) -> CGFloat
objc2-core-foundation
only.Indicates percentage of scan completed.
Sourcepub unsafe fn canPerformOverviewScan(&self) -> bool
pub unsafe fn canPerformOverviewScan(&self) -> bool
Indicates if this functional unit can perfrom an overview scan. Not all functional units can perform an overview scan. For example, a document feeder or a sheet feeder unit cannot perform an overview scan.
Sourcepub unsafe fn overviewScanInProgress(&self) -> bool
pub unsafe fn overviewScanInProgress(&self) -> bool
Indicates if an overview scan is in progress.
Sourcepub unsafe fn overviewImage(&self) -> Option<Retained<CGImage>>
Available on crate feature objc2-core-graphics
only.
pub unsafe fn overviewImage(&self) -> Option<Retained<CGImage>>
objc2-core-graphics
only.Overview scan image. This property will be NULL for functional units that do not support overview scans.
Sourcepub unsafe fn overviewResolution(&self) -> NSUInteger
pub unsafe fn overviewResolution(&self) -> NSUInteger
Overview image resolution. Value assigned to this will be contrained by resolutions allowed by the device.
Sourcepub unsafe fn setOverviewResolution(&self, overview_resolution: NSUInteger)
pub unsafe fn setOverviewResolution(&self, overview_resolution: NSUInteger)
Setter for overviewResolution
.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<AnyObject> for ICScannerFunctionalUnit
impl AsRef<AnyObject> for ICScannerFunctionalUnit
Source§impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitDocumentFeeder
impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitDocumentFeeder
Source§fn as_ref(&self) -> &ICScannerFunctionalUnit
fn as_ref(&self) -> &ICScannerFunctionalUnit
Source§impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitFlatbed
impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitFlatbed
Source§fn as_ref(&self) -> &ICScannerFunctionalUnit
fn as_ref(&self) -> &ICScannerFunctionalUnit
Source§impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitNegativeTransparency
impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitNegativeTransparency
Source§fn as_ref(&self) -> &ICScannerFunctionalUnit
fn as_ref(&self) -> &ICScannerFunctionalUnit
Source§impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitPositiveTransparency
impl AsRef<ICScannerFunctionalUnit> for ICScannerFunctionalUnitPositiveTransparency
Source§fn as_ref(&self) -> &ICScannerFunctionalUnit
fn as_ref(&self) -> &ICScannerFunctionalUnit
Source§impl AsRef<NSObject> for ICScannerFunctionalUnit
impl AsRef<NSObject> for ICScannerFunctionalUnit
Source§impl Borrow<AnyObject> for ICScannerFunctionalUnit
impl Borrow<AnyObject> for ICScannerFunctionalUnit
Source§impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitDocumentFeeder
impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitDocumentFeeder
Source§fn borrow(&self) -> &ICScannerFunctionalUnit
fn borrow(&self) -> &ICScannerFunctionalUnit
Source§impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitFlatbed
impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitFlatbed
Source§fn borrow(&self) -> &ICScannerFunctionalUnit
fn borrow(&self) -> &ICScannerFunctionalUnit
Source§impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitNegativeTransparency
impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitNegativeTransparency
Source§fn borrow(&self) -> &ICScannerFunctionalUnit
fn borrow(&self) -> &ICScannerFunctionalUnit
Source§impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitPositiveTransparency
impl Borrow<ICScannerFunctionalUnit> for ICScannerFunctionalUnitPositiveTransparency
Source§fn borrow(&self) -> &ICScannerFunctionalUnit
fn borrow(&self) -> &ICScannerFunctionalUnit
Source§impl Borrow<NSObject> for ICScannerFunctionalUnit
impl Borrow<NSObject> for ICScannerFunctionalUnit
Source§impl ClassType for ICScannerFunctionalUnit
impl ClassType for ICScannerFunctionalUnit
Source§const NAME: &'static str = "ICScannerFunctionalUnit"
const NAME: &'static str = "ICScannerFunctionalUnit"
Source§type ThreadKind = <<ICScannerFunctionalUnit as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<ICScannerFunctionalUnit as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for ICScannerFunctionalUnit
impl Debug for ICScannerFunctionalUnit
Source§impl Deref for ICScannerFunctionalUnit
impl Deref for ICScannerFunctionalUnit
Source§impl Hash for ICScannerFunctionalUnit
impl Hash for ICScannerFunctionalUnit
Source§impl Message for ICScannerFunctionalUnit
impl Message for ICScannerFunctionalUnit
Source§impl NSObjectProtocol for ICScannerFunctionalUnit
impl NSObjectProtocol for ICScannerFunctionalUnit
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref