Trait io_lifetimes::FromHandle [−][src]
pub trait FromHandle {
fn from_handle(owned: OwnedHandle) -> Self;
fn from_into_handle<Owned: IntoHandle>(into_owned: Owned) -> Self
where
Self: Sized,
{ ... }
}
Expand description
A trait to express the ability to construct an object from a handle.
Required methods
fn from_handle(owned: OwnedHandle) -> Self
fn from_handle(owned: OwnedHandle) -> Self
Constructs a new instance of Self
from the given handle.
Example
use std::fs::File;
use io_lifetimes::{FromHandle, IntoHandle, OwnedHandle};
let f = File::open("foo.txt")?;
let owned_handle: OwnedHandle = f.into_handle();
let f = File::from_handle(owned_handle);
Provided methods
fn from_into_handle<Owned: IntoHandle>(into_owned: Owned) -> Self where
Self: Sized,
fn from_into_handle<Owned: IntoHandle>(into_owned: Owned) -> Self where
Self: Sized,
Constructs a new instance of Self
from the given handle converted
from into_owned
.
Example
use std::fs::File;
use io_lifetimes::{FromHandle, IntoHandle};
let f = File::open("foo.txt")?;
let f = File::from_into_handle(f);