# 1.1.0[−][src]Trait std::os::unix::fs::MetadataExt

    pub trait MetadataExt {
        fn dev(&self) -> u64;
        fn ino(&self) -> u64;
        fn mode(&self) -> u32;
        fn nlink(&self) -> u64;
        fn uid(&self) -> u32;
        fn gid(&self) -> u32;
        fn rdev(&self) -> u64;
        fn size(&self) -> u64;
        fn atime(&self) -> i64;
        fn atime_nsec(&self) -> i64;
        fn mtime(&self) -> i64;
        fn mtime_nsec(&self) -> i64;
        fn ctime(&self) -> i64;
        fn ctime_nsec(&self) -> i64;
        fn blksize(&self) -> u64;
        fn blocks(&self) -> u64;
    }

This is supported on Unix only.

Unix-specific extensions to `fs::Metadata`.

## Required Methods

### `fn dev(&self) -> u64`

This is supported on Unix only.

Returns the ID of the device containing the file.

# Examples

    use std::io;
    use std::fs;
    use std::os::unix::fs::MetadataExt;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let dev_id = meta.dev();
        Ok(())
    }Run

### `fn ino(&self) -> u64`

This is supported on Unix only.

Returns the inode number.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let inode = meta.ino();
        Ok(())
    }Run

### `fn mode(&self) -> u32`

This is supported on Unix only.

Returns the rights applied to this file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let mode = meta.mode();
        let user_has_write_access      = mode & 0o200;
        let user_has_read_write_access = mode & 0o600;
        let group_has_read_access      = mode & 0o040;
        let others_have_exec_access    = mode & 0o001;
        Ok(())
    }Run

### `fn nlink(&self) -> u64`

This is supported on Unix only.

Returns the number of hard links pointing to this file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
     use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let nb_hard_links = meta.nlink();
        Ok(())
    }Run

### `fn uid(&self) -> u32`

This is supported on Unix only.

Returns the user ID of the owner of this file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let user_id = meta.uid();
        Ok(())
    }Run

### `fn gid(&self) -> u32`

This is supported on Unix only.

Returns the group ID of the owner of this file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let group_id = meta.gid();
        Ok(())
    }Run

### `fn rdev(&self) -> u64`

This is supported on Unix only.

Returns the device ID of this file (if it is a special one).

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let device_id = meta.rdev();
        Ok(())
    }Run

### `fn size(&self) -> u64`

This is supported on Unix only.

Returns the total size of this file in bytes.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let file_size = meta.size();
        Ok(())
    }Run

### `fn atime(&self) -> i64`

This is supported on Unix only.

Returns the time of the last access to the file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let last_access_time = meta.atime();
        Ok(())
    }Run

### `fn atime_nsec(&self) -> i64`

This is supported on Unix only.

Returns the time of the last access to the file in nanoseconds.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let nano_last_access_time = meta.atime_nsec();
        Ok(())
    }Run

### `fn mtime(&self) -> i64`

This is supported on Unix only.

Returns the time of the last modification of the file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let last_modification_time = meta.mtime();
        Ok(())
    }Run

### `fn mtime_nsec(&self) -> i64`

This is supported on Unix only.

Returns the time of the last modification of the file in nanoseconds.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let nano_last_modification_time = meta.mtime_nsec();
        Ok(())
    }Run

### `fn ctime(&self) -> i64`

This is supported on Unix only.

Returns the time of the last status change of the file.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let last_status_change_time = meta.ctime();
        Ok(())
    }Run

### `fn ctime_nsec(&self) -> i64`

This is supported on Unix only.

Returns the time of the last status change of the file in nanoseconds.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let nano_last_status_change_time = meta.ctime_nsec();
        Ok(())
    }Run

### `fn blksize(&self) -> u64`

This is supported on Unix only.

Returns the blocksize for filesystem I/O.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let blocksize = meta.blksize();
        Ok(())
    }Run

### `fn blocks(&self) -> u64`

This is supported on Unix only.

Returns the number of blocks allocated to the file, in 512-byte units.

Please note that this may be smaller than `st_size / 512` when the file has holes.

# Examples

    use std::fs;
    use std::os::unix::fs::MetadataExt;
    use std::io;

    fn main() -> io::Result<()> {
        let meta = fs::metadata("some_file")?;
        let blocks = meta.blocks();
        Ok(())
    }Run

## Implementors

###

`impl MetadataExt for Metadata`

[src]

####

`fn dev(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn ino(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn mode(&self) -> u32`

[src]

This is supported on Unix only.

####

`fn nlink(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn uid(&self) -> u32`

[src]

This is supported on Unix only.

####

`fn gid(&self) -> u32`

[src]

This is supported on Unix only.

####

`fn rdev(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn size(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn atime(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn atime_nsec(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn mtime(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn mtime_nsec(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn ctime(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn ctime_nsec(&self) -> i64`

[src]

This is supported on Unix only.

####

`fn blksize(&self) -> u64`

[src]

This is supported on Unix only.

####

`fn blocks(&self) -> u64`

[src]

This is supported on Unix only.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)