Trait io_lifetimes::AsFilelike [−][src]
pub trait AsFilelike: AsFd {
fn as_filelike(&self) -> BorrowedFilelike<'_>;
fn as_filelike_view<Target: FromFilelike + IntoFilelike>(
&self
) -> FilelikeView<'_, Target>;
}
Expand description
A portable trait to borrow a reference from an underlying filelike object.
This is a portability abstraction over Unix-like AsFd
and Windows’
AsHandle
. It also provides the as_filelike_view
convenience function
providing typed views.
Required methods
fn as_filelike(&self) -> BorrowedFilelike<'_>
fn as_filelike(&self) -> BorrowedFilelike<'_>
Borrows the reference.
Example
use std::fs::File;
use io_lifetimes::{AsFilelike, BorrowedFilelike};
let mut f = File::open("foo.txt")?;
let borrowed_filelike: BorrowedFilelike<'_> = f.as_filelike();
fn as_filelike_view<Target: FromFilelike + IntoFilelike>(
&self
) -> FilelikeView<'_, Target>
fn as_filelike_view<Target: FromFilelike + IntoFilelike>(
&self
) -> FilelikeView<'_, Target>
Return a borrowing view of a resource which dereferences to a &Target
or &mut Target
.