Skip to main content

image_capture_core/
camera_item.rs

1use cocoa::base::{id, BOOL};
2use crate::constants::ICEXIFOrientationType;
3use core_graphics::image::CGImageRef;
4use libc::c_uint;
5use libc::{c_double, off_t};
6use objc::*;
7
8/// ICCameraItem is an abstract class that represents an item in an ICCameraDevice object
9pub trait ICCameraItem: Sized {
10    /// Parent device of this folder.
11    unsafe fn device(self) -> id;
12    /// Parent folder of this folder.
13    unsafe fn parentFolder(self) -> id;
14    /// Name of this folder.
15    unsafe fn name(self) -> id;
16    /// Item UTI. This is an Uniform Type Identifier string.
17    unsafe fn UTI(self) -> id;
18    /// The file system path of the item for items on a device with transportType of ICTransportTypeMassStorage.
19    unsafe fn fileSystemPath(self) -> id;
20    /// Indicates the protection state of this folder.
21    unsafe fn isLocked(self) -> BOOL;
22    /// Indicates if the file is a raw image file.
23    unsafe fn isRaw(self) -> BOOL;
24    /// Indicates if this folder is in a temporary store.
25    unsafe fn isInTemporaryStore(self) -> BOOL;
26    /// Creation date of this file.
27    unsafe fn creationDate(self) -> id;
28    /// Modification date of this file.
29    unsafe fn modificationDate(self) -> id;
30    /// Thumbnail for the item if one is readily available.
31    unsafe fn thumbnailIfAvailable(self) -> CGImageRef;
32    /// Large thumbnail for the item if one is readily available.
33    unsafe fn largeThumbnailIfAvailable(self) -> CGImageRef;
34    /// Metadata for the file if one is readily available.
35    unsafe fn metadataIfAvailable(self) -> id;
36    /// A mutable dictionary to store arbitrary key-value pairs associated with a camera item object.
37    unsafe fn userData(self) -> id;
38    /// PTP object handle value if the item is on a camera that uses PTP protocol.
39    unsafe fn ptpObjectHandle(self) -> c_uint;
40    /// This property is set if the file is captured on the device after the device's content is fully enumerated.
41    unsafe fn wasAddedAfterContentCatalogCompleted(self) -> BOOL;
42}
43
44impl ICCameraItem for id {
45    unsafe fn device(self) -> id {
46        msg_send![self, device]
47    }
48
49    unsafe fn parentFolder(self) -> id {
50        msg_send![self, parentFolder]
51    }
52
53    unsafe fn name(self) -> id {
54        msg_send![self, name]
55    }
56
57    unsafe fn UTI(self) -> id {
58        msg_send![self, UTI]
59    }
60
61    unsafe fn fileSystemPath(self) -> id {
62        msg_send![self, fileSystemPath]
63    }
64
65    unsafe fn isLocked(self) -> BOOL {
66        msg_send![self, isLocked]
67    }
68
69    unsafe fn isRaw(self) -> BOOL {
70        msg_send![self, isRaw]
71    }
72
73    unsafe fn isInTemporaryStore(self) -> BOOL {
74        msg_send![self, isInTemporaryStore]
75    }
76
77    unsafe fn creationDate(self) -> id {
78        msg_send![self, creationDate]
79    }
80
81    unsafe fn modificationDate(self) -> id {
82        msg_send![self, modificationDate]
83    }
84
85    unsafe fn thumbnailIfAvailable(self) -> CGImageRef {
86        msg_send![self, thumbnailIfAvailable]
87    }
88
89    unsafe fn largeThumbnailIfAvailable(self) -> CGImageRef {
90        msg_send![self, largeThumbnailIfAvailable]
91    }
92
93    unsafe fn metadataIfAvailable(self) -> id {
94        msg_send![self, metadataIfAvailable]
95    }
96
97    unsafe fn userData(self) -> id {
98        msg_send![self, userData]
99    }
100
101    unsafe fn ptpObjectHandle(self) -> c_uint {
102        msg_send![self, ptpObjectHandle]
103    }
104
105    unsafe fn wasAddedAfterContentCatalogCompleted(self) -> BOOL {
106        msg_send![self, wasAddedAfterContentCatalogCompleted]
107    }
108}
109
110/// This class represents a folder on an ICCameraDevice object.
111pub trait ICCameraFolder: Sized {
112    /// A list of items contained by this folder.
113    unsafe fn contents(self) -> id;
114}
115
116impl ICCameraFolder for id {
117    unsafe fn contents(self) -> id {
118        msg_send![self, contents]
119    }
120}
121
122/// This class represents a folder on an ICCameraDevice object.
123pub trait ICCameraFile: Sized {
124    /// Size of file in bytes.
125    unsafe fn fileSize(self) -> off_t;
126    /// Desired orientation of image to use when it is downloaded.
127    unsafe fn orientation(self) -> ICEXIFOrientationType;
128    /// Duration of audio/video file in seconds.
129    unsafe fn duration(self) -> c_double;
130    /// This property is NULL if there are no sidecar files associated with this file.
131    /// Otherwise it is an array of ICCameraFile instances of sidecar files associated with this file.
132    /// An example of a sidecar file is a file with the same base name as this file and having an extension XMP.
133    unsafe fn sidecarFiles(self) -> id;
134}
135
136impl ICCameraFile for id {
137    unsafe fn fileSize(self) -> off_t {
138        msg_send![self, fileSize]
139    }
140
141    unsafe fn orientation(self) -> ICEXIFOrientationType {
142        msg_send![self, orientation]
143    }
144
145    unsafe fn duration(self) -> c_double {
146        msg_send![self, duration]
147    }
148
149    unsafe fn sidecarFiles(self) -> id {
150        msg_send![self, sidecarFiles]
151    }
152}