objc2_foundation/generated/
NSFileHandle.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10 #[unsafe(super(NSObject))]
12 #[derive(Debug, PartialEq, Eq, Hash)]
13 pub struct NSFileHandle;
14);
15
16unsafe impl Send for NSFileHandle {}
17
18unsafe impl Sync for NSFileHandle {}
19
20#[cfg(feature = "NSObject")]
21unsafe impl NSCoding for NSFileHandle {}
22
23unsafe impl NSObjectProtocol for NSFileHandle {}
24
25#[cfg(feature = "NSObject")]
26unsafe impl NSSecureCoding for NSFileHandle {}
27
28impl NSFileHandle {
29 extern_methods!(
30 #[cfg(feature = "NSData")]
31 #[unsafe(method(availableData))]
32 #[unsafe(method_family = none)]
33 pub unsafe fn availableData(&self) -> Retained<NSData>;
34
35 #[unsafe(method(initWithFileDescriptor:closeOnDealloc:))]
36 #[unsafe(method_family = init)]
37 pub unsafe fn initWithFileDescriptor_closeOnDealloc(
38 this: Allocated<Self>,
39 fd: c_int,
40 closeopt: bool,
41 ) -> Retained<Self>;
42
43 #[cfg(feature = "NSCoder")]
44 #[unsafe(method(initWithCoder:))]
45 #[unsafe(method_family = init)]
46 pub unsafe fn initWithCoder(
47 this: Allocated<Self>,
48 coder: &NSCoder,
49 ) -> Option<Retained<Self>>;
50
51 #[cfg(all(feature = "NSData", feature = "NSError"))]
52 #[unsafe(method(readDataToEndOfFileAndReturnError:_))]
53 #[unsafe(method_family = none)]
54 pub unsafe fn readDataToEndOfFileAndReturnError(
55 &self,
56 ) -> Result<Retained<NSData>, Retained<NSError>>;
57
58 #[cfg(all(feature = "NSData", feature = "NSError"))]
59 #[unsafe(method(readDataUpToLength:error:_))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn readDataUpToLength_error(
62 &self,
63 length: NSUInteger,
64 ) -> Result<Retained<NSData>, Retained<NSError>>;
65
66 #[cfg(all(feature = "NSData", feature = "NSError"))]
67 #[unsafe(method(writeData:error:_))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn writeData_error(&self, data: &NSData) -> Result<(), Retained<NSError>>;
70
71 #[cfg(feature = "NSError")]
72 #[unsafe(method(getOffset:error:_))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn getOffset_error(
75 &self,
76 offset_in_file: NonNull<c_ulonglong>,
77 ) -> Result<(), Retained<NSError>>;
78
79 #[cfg(feature = "NSError")]
80 #[unsafe(method(seekToEndReturningOffset:error:_))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn seekToEndReturningOffset_error(
83 &self,
84 offset_in_file: *mut c_ulonglong,
85 ) -> Result<(), Retained<NSError>>;
86
87 #[cfg(feature = "NSError")]
88 #[unsafe(method(seekToOffset:error:_))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn seekToOffset_error(
91 &self,
92 offset: c_ulonglong,
93 ) -> Result<(), Retained<NSError>>;
94
95 #[cfg(feature = "NSError")]
96 #[unsafe(method(truncateAtOffset:error:_))]
97 #[unsafe(method_family = none)]
98 pub unsafe fn truncateAtOffset_error(
99 &self,
100 offset: c_ulonglong,
101 ) -> Result<(), Retained<NSError>>;
102
103 #[cfg(feature = "NSError")]
104 #[unsafe(method(synchronizeAndReturnError:_))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn synchronizeAndReturnError(&self) -> Result<(), Retained<NSError>>;
107
108 #[cfg(feature = "NSError")]
109 #[unsafe(method(closeAndReturnError:_))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn closeAndReturnError(&self) -> Result<(), Retained<NSError>>;
112 );
113}
114
115impl NSFileHandle {
117 extern_methods!(
118 #[unsafe(method(init))]
119 #[unsafe(method_family = init)]
120 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122 #[unsafe(method(new))]
123 #[unsafe(method_family = new)]
124 pub unsafe fn new() -> Retained<Self>;
125 );
126}
127
128impl NSFileHandle {
130 extern_methods!(
131 #[unsafe(method(fileHandleWithStandardInput))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn fileHandleWithStandardInput() -> Retained<NSFileHandle>;
134
135 #[unsafe(method(fileHandleWithStandardOutput))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn fileHandleWithStandardOutput() -> Retained<NSFileHandle>;
138
139 #[unsafe(method(fileHandleWithStandardError))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn fileHandleWithStandardError() -> Retained<NSFileHandle>;
142
143 #[unsafe(method(fileHandleWithNullDevice))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn fileHandleWithNullDevice() -> Retained<NSFileHandle>;
146
147 #[cfg(feature = "NSString")]
148 #[unsafe(method(fileHandleForReadingAtPath:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn fileHandleForReadingAtPath(path: &NSString) -> Option<Retained<Self>>;
151
152 #[cfg(feature = "NSString")]
153 #[unsafe(method(fileHandleForWritingAtPath:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn fileHandleForWritingAtPath(path: &NSString) -> Option<Retained<Self>>;
156
157 #[cfg(feature = "NSString")]
158 #[unsafe(method(fileHandleForUpdatingAtPath:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn fileHandleForUpdatingAtPath(path: &NSString) -> Option<Retained<Self>>;
161
162 #[cfg(all(feature = "NSError", feature = "NSURL"))]
163 #[unsafe(method(fileHandleForReadingFromURL:error:_))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn fileHandleForReadingFromURL_error(
166 url: &NSURL,
167 ) -> Result<Retained<Self>, Retained<NSError>>;
168
169 #[cfg(all(feature = "NSError", feature = "NSURL"))]
170 #[unsafe(method(fileHandleForWritingToURL:error:_))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn fileHandleForWritingToURL_error(
173 url: &NSURL,
174 ) -> Result<Retained<Self>, Retained<NSError>>;
175
176 #[cfg(all(feature = "NSError", feature = "NSURL"))]
177 #[unsafe(method(fileHandleForUpdatingURL:error:_))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn fileHandleForUpdatingURL_error(
180 url: &NSURL,
181 ) -> Result<Retained<Self>, Retained<NSError>>;
182 );
183}
184
185extern "C" {
186 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
188 pub static NSFileHandleOperationException: &'static NSExceptionName;
189}
190
191extern "C" {
192 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
194 pub static NSFileHandleReadCompletionNotification: &'static NSNotificationName;
195}
196
197extern "C" {
198 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
200 pub static NSFileHandleReadToEndOfFileCompletionNotification: &'static NSNotificationName;
201}
202
203extern "C" {
204 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
206 pub static NSFileHandleConnectionAcceptedNotification: &'static NSNotificationName;
207}
208
209extern "C" {
210 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
212 pub static NSFileHandleDataAvailableNotification: &'static NSNotificationName;
213}
214
215extern "C" {
216 #[cfg(feature = "NSString")]
218 pub static NSFileHandleNotificationDataItem: &'static NSString;
219}
220
221extern "C" {
222 #[cfg(feature = "NSString")]
224 pub static NSFileHandleNotificationFileHandleItem: &'static NSString;
225}
226
227extern "C" {
228 #[cfg(feature = "NSString")]
230 pub static NSFileHandleNotificationMonitorModes: &'static NSString;
231}
232
233impl NSFileHandle {
235 extern_methods!(
236 #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
237 #[unsafe(method(readInBackgroundAndNotifyForModes:))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn readInBackgroundAndNotifyForModes(
240 &self,
241 modes: Option<&NSArray<NSRunLoopMode>>,
242 );
243
244 #[unsafe(method(readInBackgroundAndNotify))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn readInBackgroundAndNotify(&self);
247
248 #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
249 #[unsafe(method(readToEndOfFileInBackgroundAndNotifyForModes:))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn readToEndOfFileInBackgroundAndNotifyForModes(
252 &self,
253 modes: Option<&NSArray<NSRunLoopMode>>,
254 );
255
256 #[unsafe(method(readToEndOfFileInBackgroundAndNotify))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn readToEndOfFileInBackgroundAndNotify(&self);
259
260 #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
261 #[unsafe(method(acceptConnectionInBackgroundAndNotifyForModes:))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn acceptConnectionInBackgroundAndNotifyForModes(
264 &self,
265 modes: Option<&NSArray<NSRunLoopMode>>,
266 );
267
268 #[unsafe(method(acceptConnectionInBackgroundAndNotify))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn acceptConnectionInBackgroundAndNotify(&self);
271
272 #[cfg(all(feature = "NSArray", feature = "NSObjCRuntime", feature = "NSString"))]
273 #[unsafe(method(waitForDataInBackgroundAndNotifyForModes:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn waitForDataInBackgroundAndNotifyForModes(
276 &self,
277 modes: Option<&NSArray<NSRunLoopMode>>,
278 );
279
280 #[unsafe(method(waitForDataInBackgroundAndNotify))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn waitForDataInBackgroundAndNotify(&self);
283
284 #[cfg(feature = "block2")]
285 #[unsafe(method(readabilityHandler))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn readabilityHandler(
288 &self,
289 ) -> *mut block2::Block<dyn Fn(NonNull<NSFileHandle>)>;
290
291 #[cfg(feature = "block2")]
292 #[unsafe(method(setReadabilityHandler:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn setReadabilityHandler(
296 &self,
297 readability_handler: Option<&block2::Block<dyn Fn(NonNull<NSFileHandle>)>>,
298 );
299
300 #[cfg(feature = "block2")]
301 #[unsafe(method(writeabilityHandler))]
302 #[unsafe(method_family = none)]
303 pub unsafe fn writeabilityHandler(
304 &self,
305 ) -> *mut block2::Block<dyn Fn(NonNull<NSFileHandle>)>;
306
307 #[cfg(feature = "block2")]
308 #[unsafe(method(setWriteabilityHandler:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn setWriteabilityHandler(
312 &self,
313 writeability_handler: Option<&block2::Block<dyn Fn(NonNull<NSFileHandle>)>>,
314 );
315 );
316}
317
318impl NSFileHandle {
320 extern_methods!(
321 #[unsafe(method(initWithFileDescriptor:))]
322 #[unsafe(method_family = init)]
323 pub unsafe fn initWithFileDescriptor(this: Allocated<Self>, fd: c_int) -> Retained<Self>;
324
325 #[unsafe(method(fileDescriptor))]
326 #[unsafe(method_family = none)]
327 pub unsafe fn fileDescriptor(&self) -> c_int;
328 );
329}
330
331impl NSFileHandle {
332 extern_methods!(
333 #[cfg(feature = "NSData")]
334 #[deprecated]
335 #[unsafe(method(readDataToEndOfFile))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn readDataToEndOfFile(&self) -> Retained<NSData>;
338
339 #[cfg(feature = "NSData")]
340 #[deprecated]
341 #[unsafe(method(readDataOfLength:))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn readDataOfLength(&self, length: NSUInteger) -> Retained<NSData>;
344
345 #[cfg(feature = "NSData")]
346 #[deprecated]
347 #[unsafe(method(writeData:))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn writeData(&self, data: &NSData);
350
351 #[deprecated]
352 #[unsafe(method(offsetInFile))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn offsetInFile(&self) -> c_ulonglong;
355
356 #[deprecated]
357 #[unsafe(method(seekToEndOfFile))]
358 #[unsafe(method_family = none)]
359 pub unsafe fn seekToEndOfFile(&self) -> c_ulonglong;
360
361 #[deprecated]
362 #[unsafe(method(seekToFileOffset:))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn seekToFileOffset(&self, offset: c_ulonglong);
365
366 #[deprecated]
367 #[unsafe(method(truncateFileAtOffset:))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn truncateFileAtOffset(&self, offset: c_ulonglong);
370
371 #[deprecated]
372 #[unsafe(method(synchronizeFile))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn synchronizeFile(&self);
375
376 #[deprecated]
377 #[unsafe(method(closeFile))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn closeFile(&self);
380 );
381}
382
383extern_class!(
384 #[unsafe(super(NSObject))]
386 #[derive(Debug, PartialEq, Eq, Hash)]
387 pub struct NSPipe;
388);
389
390unsafe impl Send for NSPipe {}
391
392unsafe impl Sync for NSPipe {}
393
394unsafe impl NSObjectProtocol for NSPipe {}
395
396impl NSPipe {
397 extern_methods!(
398 #[unsafe(method(fileHandleForReading))]
399 #[unsafe(method_family = none)]
400 pub unsafe fn fileHandleForReading(&self) -> Retained<NSFileHandle>;
401
402 #[unsafe(method(fileHandleForWriting))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn fileHandleForWriting(&self) -> Retained<NSFileHandle>;
405
406 #[unsafe(method(pipe))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn pipe() -> Retained<NSPipe>;
409 );
410}
411
412impl NSPipe {
414 extern_methods!(
415 #[unsafe(method(init))]
416 #[unsafe(method_family = init)]
417 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
418
419 #[unsafe(method(new))]
420 #[unsafe(method_family = new)]
421 pub unsafe fn new() -> Retained<Self>;
422 );
423}