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