Trait io_lifetimes::AsFilelike[][src]

pub trait AsFilelike: AsHandle {
    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

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();

Return a borrowing view of a resource which dereferences to a &Target or &mut Target.

Implementors