Lines Matching defs:LocalFile
154 /// To represent files that are not thread safe due to this optimization, the [`LocalFile`] type is
223 /// [`assume_no_fdget_pos`]: LocalFile::assume_no_fdget_pos
225 pub struct LocalFile {
229 // SAFETY: The type invariants guarantee that `LocalFile` is always ref-counted. This implementation
230 // makes `ARef<LocalFile>` own a normal refcount.
231 unsafe impl AlwaysRefCounted for LocalFile {
239 unsafe fn dec_ref(obj: ptr::NonNull<LocalFile>) {
241 // may drop it. The cast is okay since `LocalFile` has the same representation as
247 impl LocalFile {
255 /// [`assume_no_fdget_pos`]: LocalFile::assume_no_fdget_pos
257 pub fn fget(fd: u32) -> Result<ARef<LocalFile>, BadFdError> {
269 /// Creates a reference to a [`LocalFile`] from a valid pointer.
278 pub unsafe fn from_raw_file<'a>(ptr: *const bindings::file) -> &'a LocalFile {
280 // duration of `'a`. The cast is okay because `LocalFile` is `repr(transparent)`.
292 /// This method is intended to be used together with [`LocalFile::fget`] when the caller knows
301 pub unsafe fn assume_no_fdget_pos(me: ARef<LocalFile>) -> ARef<File> {
306 // SAFETY: `LocalFile` and `File` have the same layout.
361 // Make LocalFile methods available on File.
363 type Target = LocalFile;
365 fn deref(&self) -> &LocalFile {
371 unsafe { LocalFile::from_raw_file(core::ptr::from_ref(self).cast()) }