objc2_fs_kit/generated/
FSFileName.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// The name of a file, expressed as a data buffer.
12    ///
13    /// `FSFileName` is the class that carries filenames from the kernel to `FSModule` instances, and carries names back to the kernel as part of directory enumeration.
14    ///
15    /// A filename is usually a valid UTF-8 sequence, but can be an arbitrary byte sequence that doesn't conform to that format.
16    /// As a result, the ``data`` property always contains a value, but the ``string`` property may be empty.
17    /// An `FSModule` can receive an `FSFileName` that isn't valid UTF-8 in two cases:
18    /// 1. A program passes erroneous data to a system call. The `FSModule` treats this situation as an error.
19    /// 2. An `FSModule` lacks the character encoding used for a file name.
20    /// This situation occurs because some file system formats consider a filename to be an arbitrary "bag of bytes," and leave character encoding up to the operating system.
21    /// Without encoding information, the `FSModule` can only pass back the names it finds on disk.
22    /// In this case, the behavior of upper layers such as
23    /// <doc
24    /// ://com.apple.documentation/documentation/Foundation/NSFileManager> is unspecified.
25    /// However, the `FSModule` must support looking up such names and using them as the source name of rename operations.
26    /// The `FSModule` must also be able to support filenames that are derivatives of filenames returned from directory enumeration.
27    /// Derivative filenames include Apple Double filenames (`"._Name"`), and editor backup filenames.
28    ///
29    /// > Important: Don't subclass this class.
30    ///
31    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsfilename?language=objc)
32    #[unsafe(super(NSObject))]
33    #[derive(Debug, PartialEq, Eq, Hash)]
34    pub struct FSFileName;
35);
36
37extern_conformance!(
38    unsafe impl NSCoding for FSFileName {}
39);
40
41extern_conformance!(
42    unsafe impl NSCopying for FSFileName {}
43);
44
45unsafe impl CopyingHelper for FSFileName {
46    type Result = Self;
47}
48
49extern_conformance!(
50    unsafe impl NSObjectProtocol for FSFileName {}
51);
52
53extern_conformance!(
54    unsafe impl NSSecureCoding for FSFileName {}
55);
56
57impl FSFileName {
58    extern_methods!(
59        /// The byte sequence of the filename, as a data object.
60        ///
61        /// This property always provides a value.
62        #[unsafe(method(data))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn data(&self) -> Retained<NSData>;
65
66        /// The filename, represented as a Unicode string.
67        ///
68        /// If the value of the filename's ``FSFileName/data`` is not a valid UTF-8 byte sequence, this property is empty.
69        #[unsafe(method(string))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn string(&self) -> Option<Retained<NSString>>;
72
73        /// The filename, represented as a potentially lossy conversion to a string.
74        ///
75        /// The exact details of the string conversion may change in the future.
76        #[unsafe(method(debugDescription))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn debugDescription(&self) -> Retained<NSString>;
79
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        /// Initializes a filename from a null-terminated character sequence.
85        ///
86        /// > Note: This initializer is unavailable in Swift. Use ``initWithData:`` or ``initWithString:`` instead.
87        ///
88        /// - Parameter name: A pointer to a C string.
89        ///
90        /// # Safety
91        ///
92        /// `name` must be a valid pointer.
93        #[unsafe(method(initWithCString:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithCString(
96            this: Allocated<Self>,
97            name: NonNull<c_char>,
98        ) -> Retained<Self>;
99
100        /// Initializes a file name by copying a character sequence from a byte array.
101        ///
102        /// > Note: This initializer is unavailable in Swift. Use ``initWithData:`` or ``initWithString:`` instead.
103        ///
104        /// - Parameters:
105        /// - bytes: A pointer to the character data to copy, up to a maximum of `length`. The sequence terminates if a `NUL` character exists prior to `length`.
106        /// - length: The size of the `bytes` array.
107        ///
108        /// # Safety
109        ///
110        /// `bytes` must be a valid pointer.
111        #[unsafe(method(initWithBytes:length:))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn initWithBytes_length(
114            this: Allocated<Self>,
115            bytes: NonNull<c_char>,
116            length: NSUInteger,
117        ) -> Retained<Self>;
118
119        /// Creates a filename by copying a character sequence data object.
120        ///
121        /// This initializer copies up to `name.length` characters of the sequence pointed to by `bytes`.
122        ///
123        /// - Parameter name: The data object containing the character sequence to use for the filename. The sequence terminates if a `NUL` character exists prior to `name.length`.
124        #[unsafe(method(initWithData:))]
125        #[unsafe(method_family = init)]
126        pub unsafe fn initWithData(this: Allocated<Self>, name: &NSData) -> Retained<Self>;
127
128        /// Creates a filename by copying a character sequence from a string instance.
129        ///
130        /// This initializer copies the UTF-8 representation of the characters in `string`.
131        /// If `string` contains a `NUL` character, the sequence terminates.
132        ///
133        /// - Parameter name: The string containing the character sequence to use for the filename.
134        #[unsafe(method(initWithString:))]
135        #[unsafe(method_family = init)]
136        pub unsafe fn initWithString(this: Allocated<Self>, name: &NSString) -> Retained<Self>;
137
138        /// Creates a filename from a null-terminated character sequence.
139        ///
140        /// - Parameter name: A pointer to a C string.
141        ///
142        /// # Safety
143        ///
144        /// `name` must be a valid pointer.
145        #[unsafe(method(nameWithCString:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn nameWithCString(name: NonNull<c_char>) -> Retained<Self>;
148
149        /// Creates a filename by copying a character sequence from a byte array.
150        ///
151        /// - Parameters:
152        /// - bytes: A pointer to the character data to copy, up to a maximum of `length`. The sequence terminates if a `NUL` character exists prior to `length`.
153        /// - length: The size of the `bytes` array.
154        ///
155        /// # Safety
156        ///
157        /// `bytes` must be a valid pointer.
158        #[unsafe(method(nameWithBytes:length:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn nameWithBytes_length(
161            bytes: NonNull<c_char>,
162            length: NSUInteger,
163        ) -> Retained<Self>;
164
165        /// Creates a filename by copying a character sequence data object.
166        ///
167        /// This initializer copies up to `name.length` characters of the sequence pointed to by `bytes`.
168        ///
169        /// - Parameter name: The data object containing the character sequence to use for the filename. The sequence terminates if a `NUL` character exists prior to `name.length`.
170        #[unsafe(method(nameWithData:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn nameWithData(name: &NSData) -> Retained<Self>;
173
174        /// Creates a filename by copying a character sequence from a string instance.
175        ///
176        /// This initializer copies the UTF-8 representation of the characters in `string`.
177        /// If `string` contains a `NUL` character, the sequence terminates.
178        ///
179        /// - Parameter name: The string containing the character sequence to use for the filename.
180        #[unsafe(method(nameWithString:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn nameWithString(name: &NSString) -> Retained<Self>;
183    );
184}
185
186/// Methods declared on superclass `NSObject`.
187impl FSFileName {
188    extern_methods!(
189        #[unsafe(method(new))]
190        #[unsafe(method_family = new)]
191        pub unsafe fn new() -> Retained<Self>;
192    );
193}