Struct File

Source
pub struct File(/* private fields */);

Implementations§

Source§

impl File

Source

pub fn open(path: &UnixStr) -> Result<Self>

Opens a file with default options

§Errors

Operating system errors ond finding and reading files

Source

pub const unsafe fn from_raw_fd(fd: RawFd) -> Self

Create a File from a raw fd

§Safety

The fd is valid and is not duplicated. Duplication is bad since the fd will be closed when this File is dropped

Source

pub fn set_nonblocking(&self) -> Result<()>

Set this File to be non-blocking. This will result in for example read expecting a certain number of bytes to fail with EAGAIN if that data isn’t available.

§Errors

Errors making the underlying syscalls

Source

pub fn metadata(&self) -> Result<Metadata>

Get file metadata for this open File

§Errors

Os errors making the stat-syscall

Source

pub fn copy(&self, dest: &UnixStr) -> Result<Self>

Copies src to dest, can be used to move files. Will overwrite anything currently at dest. Returns a handle to the new file.

§Errors

Os errors relating to file access

Trait Implementations§

Source§

impl AsRawFd for File

Source§

impl Read for File

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Read into to provided buffer Read more
Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Reads to the end of this Reader, Read more
Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize>

Reads to the end of the provided buffer Read more
Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>

Reads exactly enough bytes to fill the buffer Read more
Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Get this reader by mut ref Read more
Source§

impl Write for File

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Tries to write the contents of the provided buffer into this writer returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this Writer Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

Writes the full buffer into this Writer Read more
Source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<()>

Writes format arguments into this Writer Read more
Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Get this Writer as a mutable reference

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.