objc2_foundation/generated/
NSFileWrapper.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::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsfilewrapperreadingoptions?language=objc)
10// NS_OPTIONS
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSFileWrapperReadingOptions(pub NSUInteger);
14bitflags::bitflags! {
15    impl NSFileWrapperReadingOptions: NSUInteger {
16        #[doc(alias = "NSFileWrapperReadingImmediate")]
17        const Immediate = 1<<0;
18        #[doc(alias = "NSFileWrapperReadingWithoutMapping")]
19        const WithoutMapping = 1<<1;
20    }
21}
22
23unsafe impl Encode for NSFileWrapperReadingOptions {
24    const ENCODING: Encoding = NSUInteger::ENCODING;
25}
26
27unsafe impl RefEncode for NSFileWrapperReadingOptions {
28    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsfilewrapperwritingoptions?language=objc)
32// NS_OPTIONS
33#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct NSFileWrapperWritingOptions(pub NSUInteger);
36bitflags::bitflags! {
37    impl NSFileWrapperWritingOptions: NSUInteger {
38        #[doc(alias = "NSFileWrapperWritingAtomic")]
39        const Atomic = 1<<0;
40        #[doc(alias = "NSFileWrapperWritingWithNameUpdating")]
41        const WithNameUpdating = 1<<1;
42    }
43}
44
45unsafe impl Encode for NSFileWrapperWritingOptions {
46    const ENCODING: Encoding = NSUInteger::ENCODING;
47}
48
49unsafe impl RefEncode for NSFileWrapperWritingOptions {
50    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53extern_class!(
54    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsfilewrapper?language=objc)
55    #[unsafe(super(NSObject))]
56    #[derive(Debug, PartialEq, Eq, Hash)]
57    pub struct NSFileWrapper;
58);
59
60#[cfg(feature = "NSObject")]
61extern_conformance!(
62    unsafe impl NSCoding for NSFileWrapper {}
63);
64
65extern_conformance!(
66    unsafe impl NSObjectProtocol for NSFileWrapper {}
67);
68
69#[cfg(feature = "NSObject")]
70extern_conformance!(
71    unsafe impl NSSecureCoding for NSFileWrapper {}
72);
73
74impl NSFileWrapper {
75    extern_methods!(
76        #[cfg(all(feature = "NSError", feature = "NSURL"))]
77        #[unsafe(method(initWithURL:options:error:_))]
78        #[unsafe(method_family = init)]
79        pub unsafe fn initWithURL_options_error(
80            this: Allocated<Self>,
81            url: &NSURL,
82            options: NSFileWrapperReadingOptions,
83        ) -> Result<Retained<Self>, Retained<NSError>>;
84
85        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
86        #[unsafe(method(initDirectoryWithFileWrappers:))]
87        #[unsafe(method_family = init)]
88        pub unsafe fn initDirectoryWithFileWrappers(
89            this: Allocated<Self>,
90            children_by_preferred_name: &NSDictionary<NSString, NSFileWrapper>,
91        ) -> Retained<Self>;
92
93        #[cfg(feature = "NSData")]
94        #[unsafe(method(initRegularFileWithContents:))]
95        #[unsafe(method_family = init)]
96        pub unsafe fn initRegularFileWithContents(
97            this: Allocated<Self>,
98            contents: &NSData,
99        ) -> Retained<Self>;
100
101        #[cfg(feature = "NSURL")]
102        #[unsafe(method(initSymbolicLinkWithDestinationURL:))]
103        #[unsafe(method_family = init)]
104        pub unsafe fn initSymbolicLinkWithDestinationURL(
105            this: Allocated<Self>,
106            url: &NSURL,
107        ) -> Retained<Self>;
108
109        #[cfg(feature = "NSData")]
110        #[unsafe(method(initWithSerializedRepresentation:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithSerializedRepresentation(
113            this: Allocated<Self>,
114            serialize_representation: &NSData,
115        ) -> Option<Retained<Self>>;
116
117        #[cfg(feature = "NSCoder")]
118        #[unsafe(method(initWithCoder:))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn initWithCoder(
121            this: Allocated<Self>,
122            in_coder: &NSCoder,
123        ) -> Option<Retained<Self>>;
124
125        #[unsafe(method(isDirectory))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn isDirectory(&self) -> bool;
128
129        #[unsafe(method(isRegularFile))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn isRegularFile(&self) -> bool;
132
133        #[unsafe(method(isSymbolicLink))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn isSymbolicLink(&self) -> bool;
136
137        #[cfg(feature = "NSString")]
138        #[unsafe(method(preferredFilename))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn preferredFilename(&self) -> Option<Retained<NSString>>;
141
142        #[cfg(feature = "NSString")]
143        /// Setter for [`preferredFilename`][Self::preferredFilename].
144        #[unsafe(method(setPreferredFilename:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn setPreferredFilename(&self, preferred_filename: Option<&NSString>);
147
148        #[cfg(feature = "NSString")]
149        #[unsafe(method(filename))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn filename(&self) -> Option<Retained<NSString>>;
152
153        #[cfg(feature = "NSString")]
154        /// Setter for [`filename`][Self::filename].
155        #[unsafe(method(setFilename:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setFilename(&self, filename: Option<&NSString>);
158
159        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
160        #[unsafe(method(fileAttributes))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn fileAttributes(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
163
164        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
165        /// Setter for [`fileAttributes`][Self::fileAttributes].
166        #[unsafe(method(setFileAttributes:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setFileAttributes(&self, file_attributes: &NSDictionary<NSString, AnyObject>);
169
170        #[cfg(feature = "NSURL")]
171        #[unsafe(method(matchesContentsOfURL:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn matchesContentsOfURL(&self, url: &NSURL) -> bool;
174
175        #[cfg(all(feature = "NSError", feature = "NSURL"))]
176        #[unsafe(method(readFromURL:options:error:_))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn readFromURL_options_error(
179            &self,
180            url: &NSURL,
181            options: NSFileWrapperReadingOptions,
182        ) -> Result<(), Retained<NSError>>;
183
184        #[cfg(all(feature = "NSError", feature = "NSURL"))]
185        #[unsafe(method(writeToURL:options:originalContentsURL:error:_))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn writeToURL_options_originalContentsURL_error(
188            &self,
189            url: &NSURL,
190            options: NSFileWrapperWritingOptions,
191            original_contents_url: Option<&NSURL>,
192        ) -> Result<(), Retained<NSError>>;
193
194        #[cfg(feature = "NSData")]
195        #[unsafe(method(serializedRepresentation))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn serializedRepresentation(&self) -> Option<Retained<NSData>>;
198
199        #[cfg(feature = "NSString")]
200        #[unsafe(method(addFileWrapper:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn addFileWrapper(&self, child: &NSFileWrapper) -> Retained<NSString>;
203
204        #[cfg(all(feature = "NSData", feature = "NSString"))]
205        #[unsafe(method(addRegularFileWithContents:preferredFilename:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn addRegularFileWithContents_preferredFilename(
208            &self,
209            data: &NSData,
210            file_name: &NSString,
211        ) -> Retained<NSString>;
212
213        #[unsafe(method(removeFileWrapper:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn removeFileWrapper(&self, child: &NSFileWrapper);
216
217        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
218        #[unsafe(method(fileWrappers))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn fileWrappers(
221            &self,
222        ) -> Option<Retained<NSDictionary<NSString, NSFileWrapper>>>;
223
224        #[cfg(feature = "NSString")]
225        #[unsafe(method(keyForFileWrapper:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn keyForFileWrapper(&self, child: &NSFileWrapper)
228            -> Option<Retained<NSString>>;
229
230        #[cfg(feature = "NSData")]
231        #[unsafe(method(regularFileContents))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn regularFileContents(&self) -> Option<Retained<NSData>>;
234
235        #[cfg(feature = "NSURL")]
236        #[unsafe(method(symbolicLinkDestinationURL))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn symbolicLinkDestinationURL(&self) -> Option<Retained<NSURL>>;
239    );
240}
241
242/// Methods declared on superclass `NSObject`.
243impl NSFileWrapper {
244    extern_methods!(
245        #[unsafe(method(init))]
246        #[unsafe(method_family = init)]
247        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
248
249        #[unsafe(method(new))]
250        #[unsafe(method_family = new)]
251        pub unsafe fn new() -> Retained<Self>;
252    );
253}
254
255/// NSDeprecated.
256impl NSFileWrapper {
257    extern_methods!(
258        #[cfg(feature = "NSString")]
259        #[deprecated = "Use -initWithURL:options:error: instead."]
260        #[unsafe(method(initWithPath:))]
261        #[unsafe(method_family = init)]
262        pub unsafe fn initWithPath(
263            this: Allocated<Self>,
264            path: &NSString,
265        ) -> Option<Retained<Self>>;
266
267        #[cfg(feature = "NSString")]
268        #[deprecated = "Use -initSymbolicLinkWithDestinationURL: and -setPreferredFileName:, if necessary, instead."]
269        #[unsafe(method(initSymbolicLinkWithDestination:))]
270        #[unsafe(method_family = init)]
271        pub unsafe fn initSymbolicLinkWithDestination(
272            this: Allocated<Self>,
273            path: &NSString,
274        ) -> Retained<Self>;
275
276        #[cfg(feature = "NSString")]
277        #[deprecated = "Use -matchesContentsOfURL: instead."]
278        #[unsafe(method(needsToBeUpdatedFromPath:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn needsToBeUpdatedFromPath(&self, path: &NSString) -> bool;
281
282        #[cfg(feature = "NSString")]
283        #[deprecated = "Use -readFromURL:options:error: instead."]
284        #[unsafe(method(updateFromPath:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn updateFromPath(&self, path: &NSString) -> bool;
287
288        #[cfg(feature = "NSString")]
289        #[deprecated = "Use -writeToURL:options:originalContentsURL:error: instead."]
290        #[unsafe(method(writeToFile:atomically:updateFilenames:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn writeToFile_atomically_updateFilenames(
293            &self,
294            path: &NSString,
295            atomic_flag: bool,
296            update_filenames_flag: bool,
297        ) -> bool;
298
299        #[cfg(feature = "NSString")]
300        #[deprecated = "Instantiate a new NSFileWrapper with -initWithURL:options:error:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
301        #[unsafe(method(addFileWithPath:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn addFileWithPath(&self, path: &NSString) -> Retained<NSString>;
304
305        #[cfg(feature = "NSString")]
306        #[deprecated = "Instantiate a new NSFileWrapper with -initWithSymbolicLinkDestinationURL:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
307        #[unsafe(method(addSymbolicLinkWithDestination:preferredFilename:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn addSymbolicLinkWithDestination_preferredFilename(
310            &self,
311            path: &NSString,
312            filename: &NSString,
313        ) -> Retained<NSString>;
314
315        #[cfg(feature = "NSString")]
316        #[deprecated = "Use -symbolicLinkDestinationURL instead."]
317        #[unsafe(method(symbolicLinkDestination))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn symbolicLinkDestination(&self) -> Retained<NSString>;
320    );
321}