Trait unsafe_io::AsUnsafeFile[][src]

pub unsafe trait AsUnsafeFile: AsUnsafeHandle {
    fn as_unsafe_file(&self) -> UnsafeFile;

    fn as_file_view(&self) -> View<'_, File> { ... }
unsafe fn as_unscoped_file_view(&self) -> View<'static, File> { ... }
fn eq_file<Filelike: AsUnsafeFile>(&self, other: &Filelike) -> bool { ... } }
Expand description

A trait for types which contain an unsafe file and can expose it.

A type implementing AsUnsafeFile guarantees that the return value from as_unsafe_file on an instance of the type is a copy of a handle which is owned.

Safety

This trait is unsafe because types implementing it must guarantee they own their handle.

Required methods

Return the contained unsafe file.

Provided methods

Utility for returning a value which dereferences to a &File or &mut File.

Note that AsUnsafeFile may be implemented for types which are not normal files, and which don’t support all the methods on File.

Like as_file_view, but returns a value which is not explicitly tied to the lifetime of self.

Safety

Callers must manually ensure that the view doesn’t outlive self.

Test whether self.as_unsafe_file().as_unsafe_handle() is equal to other.as_unsafe_file().as_unsafe_handle().

That this depends on the guarantee that types that implement AsUnsafeFile own their resources, so we won’t erroneously compare dangling handles.

Implementors