objc2_foundation/generated/
NSFileWrapper.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[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#[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 #[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 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 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 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 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 fn initWithSerializedRepresentation(
113 this: Allocated<Self>,
114 serialize_representation: &NSData,
115 ) -> Option<Retained<Self>>;
116
117 #[cfg(feature = "NSCoder")]
118 #[unsafe(method(initWithCoder:))]
122 #[unsafe(method_family = init)]
123 pub unsafe fn initWithCoder(
124 this: Allocated<Self>,
125 in_coder: &NSCoder,
126 ) -> Option<Retained<Self>>;
127
128 #[unsafe(method(isDirectory))]
129 #[unsafe(method_family = none)]
130 pub fn isDirectory(&self) -> bool;
131
132 #[unsafe(method(isRegularFile))]
133 #[unsafe(method_family = none)]
134 pub fn isRegularFile(&self) -> bool;
135
136 #[unsafe(method(isSymbolicLink))]
137 #[unsafe(method_family = none)]
138 pub fn isSymbolicLink(&self) -> bool;
139
140 #[cfg(feature = "NSString")]
141 #[unsafe(method(preferredFilename))]
142 #[unsafe(method_family = none)]
143 pub fn preferredFilename(&self) -> Option<Retained<NSString>>;
144
145 #[cfg(feature = "NSString")]
146 #[unsafe(method(setPreferredFilename:))]
150 #[unsafe(method_family = none)]
151 pub fn setPreferredFilename(&self, preferred_filename: Option<&NSString>);
152
153 #[cfg(feature = "NSString")]
154 #[unsafe(method(filename))]
155 #[unsafe(method_family = none)]
156 pub fn filename(&self) -> Option<Retained<NSString>>;
157
158 #[cfg(feature = "NSString")]
159 #[unsafe(method(setFilename:))]
163 #[unsafe(method_family = none)]
164 pub fn setFilename(&self, filename: Option<&NSString>);
165
166 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
167 #[unsafe(method(fileAttributes))]
168 #[unsafe(method_family = none)]
169 pub fn fileAttributes(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
170
171 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
172 #[unsafe(method(setFileAttributes:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn setFileAttributes(&self, file_attributes: &NSDictionary<NSString, AnyObject>);
182
183 #[cfg(feature = "NSURL")]
184 #[unsafe(method(matchesContentsOfURL:))]
185 #[unsafe(method_family = none)]
186 pub fn matchesContentsOfURL(&self, url: &NSURL) -> bool;
187
188 #[cfg(all(feature = "NSError", feature = "NSURL"))]
189 #[unsafe(method(readFromURL:options:error:_))]
190 #[unsafe(method_family = none)]
191 pub fn readFromURL_options_error(
192 &self,
193 url: &NSURL,
194 options: NSFileWrapperReadingOptions,
195 ) -> Result<(), Retained<NSError>>;
196
197 #[cfg(all(feature = "NSError", feature = "NSURL"))]
198 #[unsafe(method(writeToURL:options:originalContentsURL:error:_))]
199 #[unsafe(method_family = none)]
200 pub fn writeToURL_options_originalContentsURL_error(
201 &self,
202 url: &NSURL,
203 options: NSFileWrapperWritingOptions,
204 original_contents_url: Option<&NSURL>,
205 ) -> Result<(), Retained<NSError>>;
206
207 #[cfg(feature = "NSData")]
208 #[unsafe(method(serializedRepresentation))]
209 #[unsafe(method_family = none)]
210 pub fn serializedRepresentation(&self) -> Option<Retained<NSData>>;
211
212 #[cfg(feature = "NSString")]
213 #[unsafe(method(addFileWrapper:))]
214 #[unsafe(method_family = none)]
215 pub fn addFileWrapper(&self, child: &NSFileWrapper) -> Retained<NSString>;
216
217 #[cfg(all(feature = "NSData", feature = "NSString"))]
218 #[unsafe(method(addRegularFileWithContents:preferredFilename:))]
219 #[unsafe(method_family = none)]
220 pub fn addRegularFileWithContents_preferredFilename(
221 &self,
222 data: &NSData,
223 file_name: &NSString,
224 ) -> Retained<NSString>;
225
226 #[unsafe(method(removeFileWrapper:))]
227 #[unsafe(method_family = none)]
228 pub fn removeFileWrapper(&self, child: &NSFileWrapper);
229
230 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
231 #[unsafe(method(fileWrappers))]
232 #[unsafe(method_family = none)]
233 pub fn fileWrappers(&self) -> Option<Retained<NSDictionary<NSString, NSFileWrapper>>>;
234
235 #[cfg(feature = "NSString")]
236 #[unsafe(method(keyForFileWrapper:))]
237 #[unsafe(method_family = none)]
238 pub fn keyForFileWrapper(&self, child: &NSFileWrapper) -> Option<Retained<NSString>>;
239
240 #[cfg(feature = "NSData")]
241 #[unsafe(method(regularFileContents))]
242 #[unsafe(method_family = none)]
243 pub fn regularFileContents(&self) -> Option<Retained<NSData>>;
244
245 #[cfg(feature = "NSURL")]
246 #[unsafe(method(symbolicLinkDestinationURL))]
247 #[unsafe(method_family = none)]
248 pub fn symbolicLinkDestinationURL(&self) -> Option<Retained<NSURL>>;
249 );
250}
251
252impl NSFileWrapper {
254 extern_methods!(
255 #[unsafe(method(init))]
256 #[unsafe(method_family = init)]
257 pub fn init(this: Allocated<Self>) -> Retained<Self>;
258
259 #[unsafe(method(new))]
260 #[unsafe(method_family = new)]
261 pub fn new() -> Retained<Self>;
262 );
263}
264
265impl DefaultRetained for NSFileWrapper {
266 #[inline]
267 fn default_retained() -> Retained<Self> {
268 Self::new()
269 }
270}
271
272impl NSFileWrapper {
274 extern_methods!(
275 #[cfg(feature = "NSString")]
276 #[deprecated = "Use -initWithURL:options:error: instead."]
277 #[unsafe(method(initWithPath:))]
278 #[unsafe(method_family = init)]
279 pub fn initWithPath(this: Allocated<Self>, path: &NSString) -> Option<Retained<Self>>;
280
281 #[cfg(feature = "NSString")]
282 #[deprecated = "Use -initSymbolicLinkWithDestinationURL: and -setPreferredFileName:, if necessary, instead."]
283 #[unsafe(method(initSymbolicLinkWithDestination:))]
284 #[unsafe(method_family = init)]
285 pub fn initSymbolicLinkWithDestination(
286 this: Allocated<Self>,
287 path: &NSString,
288 ) -> Retained<Self>;
289
290 #[cfg(feature = "NSString")]
291 #[deprecated = "Use -matchesContentsOfURL: instead."]
292 #[unsafe(method(needsToBeUpdatedFromPath:))]
293 #[unsafe(method_family = none)]
294 pub fn needsToBeUpdatedFromPath(&self, path: &NSString) -> bool;
295
296 #[cfg(feature = "NSString")]
297 #[deprecated = "Use -readFromURL:options:error: instead."]
298 #[unsafe(method(updateFromPath:))]
299 #[unsafe(method_family = none)]
300 pub fn updateFromPath(&self, path: &NSString) -> bool;
301
302 #[cfg(feature = "NSString")]
303 #[deprecated = "Use -writeToURL:options:originalContentsURL:error: instead."]
304 #[unsafe(method(writeToFile:atomically:updateFilenames:))]
305 #[unsafe(method_family = none)]
306 pub fn writeToFile_atomically_updateFilenames(
307 &self,
308 path: &NSString,
309 atomic_flag: bool,
310 update_filenames_flag: bool,
311 ) -> bool;
312
313 #[cfg(feature = "NSString")]
314 #[deprecated = "Instantiate a new NSFileWrapper with -initWithURL:options:error:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
315 #[unsafe(method(addFileWithPath:))]
316 #[unsafe(method_family = none)]
317 pub fn addFileWithPath(&self, path: &NSString) -> Retained<NSString>;
318
319 #[cfg(feature = "NSString")]
320 #[deprecated = "Instantiate a new NSFileWrapper with -initWithSymbolicLinkDestinationURL:, send it -setPreferredFileName: if necessary, then use -addFileWrapper: instead."]
321 #[unsafe(method(addSymbolicLinkWithDestination:preferredFilename:))]
322 #[unsafe(method_family = none)]
323 pub fn addSymbolicLinkWithDestination_preferredFilename(
324 &self,
325 path: &NSString,
326 filename: &NSString,
327 ) -> Retained<NSString>;
328
329 #[cfg(feature = "NSString")]
330 #[deprecated = "Use -symbolicLinkDestinationURL instead."]
331 #[unsafe(method(symbolicLinkDestination))]
332 #[unsafe(method_family = none)]
333 pub fn symbolicLinkDestination(&self) -> Retained<NSString>;
334 );
335}