[][src]Trait dpdk_unix::PathExt

pub trait PathExt {
    fn to_c_string(&self) -> CString;
fn make_file_read_write_all(&self) -> Result<()>;
fn make_folder_searchable_to_all(&self) -> Result<()>;
fn read_hexadecimal_value_with_prefix<P: Fn(&str) -> Result<T, ParseIntError>, T>(
        &self,
        size: usize,
        parser: P
    ) -> Result<T>;
fn read_raw(&self) -> Result<Box<[u8]>>;
fn read_raw_without_line_feed(&self) -> Result<Box<[u8]>>;
fn read_raw_string(&self) -> Result<String>;
fn read_string_without_line_feed(&self) -> Result<String>;
fn read_value<F>(&self) -> Result<F>
    where
        F: FromStr,
        <F as FromStr>::Err: 'static + Send + Sync + Error
;
fn write_value<D: Display>(&self, value: D) -> Result<()>;
fn read_linux_core_or_numa_list<Mapper: Fn(u16) -> R, R: Ord>(
        &self,
        mapper: Mapper
    ) -> Result<BTreeSet<R>, ListParseError>;
fn parse_linux_core_or_numa_bitmask(&self) -> Result<u32, Error>;
fn parse_process_status_file(
        &self
    ) -> Result<ProcessStatusStatistics, ProcessStatusFileParseError>;
fn parse_virtual_memory_statistics_file(
        &self
    ) -> Result<HashMap<VirtualMemoryStatisticName, u64>>;
fn parse_memory_information_file(
        &self,
        memory_information_name_prefix: &[u8]
    ) -> Result<MemoryInformation, MemoryInformationParseError>; fn read_hexadecimal_value_with_prefix_u16(&self) -> Result<u16> { ... } }

An extension trait to make it easier to work with sys and proc files and folders.

Required methods

fn to_c_string(&self) -> CString

Converts a Path to a CString.

fn make_file_read_write_all(&self) -> Result<()>

Makes a file read-write to all.

fn make_folder_searchable_to_all(&self) -> Result<()>

Makes a folder searchable to all (ie gives it read and execute permissions).

fn read_hexadecimal_value_with_prefix<P: Fn(&str) -> Result<T, ParseIntError>, T>(
    &self,
    size: usize,
    parser: P
) -> Result<T>

Reads a value from a file which is line-feed terminated and is hexadecimal using a parser.

fn read_raw(&self) -> Result<Box<[u8]>>

Reads a file as bytes.

Fails if empty.

fn read_raw_without_line_feed(&self) -> Result<Box<[u8]>>

Reads a file as bytes, expecting a final line feed.

The returned bytes lack a final line feed.

fn read_raw_string(&self) -> Result<String>

Reads a file as a string.

Fails if empty.

fn read_string_without_line_feed(&self) -> Result<String>

Reads a file as a string, expecting a final line feed.

The returned string lacks a final line feed.

fn read_value<F>(&self) -> Result<F> where
    F: FromStr,
    <F as FromStr>::Err: 'static + Send + Sync + Error

Reads a value from a file which is line-feed terminated.

fn write_value<D: Display>(&self, value: D) -> Result<()>

Writes a value to a file which is line-feed terminated.

fn read_linux_core_or_numa_list<Mapper: Fn(u16) -> R, R: Ord>(
    &self,
    mapper: Mapper
) -> Result<BTreeSet<R>, ListParseError>

Reads and parses a linux core or numa list string from a file.

Returns a BTreeSet with the zero-based indices found in the string. For example, "2,4-31,32-63" would return a set with all values between 0 to 63 except 0, 1 and 3.

fn parse_linux_core_or_numa_bitmask(&self) -> Result<u32, Error>

Reads and parses a linux core or numa mask string from a file.

fn parse_process_status_file(
    &self
) -> Result<ProcessStatusStatistics, ProcessStatusFileParseError>

Parses a process status, such as /proc/status/self.

fn parse_virtual_memory_statistics_file(
    &self
) -> Result<HashMap<VirtualMemoryStatisticName, u64>>

Parses a virtual memory statistics file (vmstat).

fn parse_memory_information_file(
    &self,
    memory_information_name_prefix: &[u8]
) -> Result<MemoryInformation, MemoryInformationParseError>

Parses a memory information file (meminfo).

Loading content...

Provided methods

fn read_hexadecimal_value_with_prefix_u16(&self) -> Result<u16>

Reads a value from a file which is line-feed terminated and is hexadecimal into an u16.

Loading content...

Implementations on Foreign Types

impl PathExt for Path[src]

fn parse_memory_information_file(
    &self,
    memory_information_name_prefix: &[u8]
) -> Result<MemoryInformation, MemoryInformationParseError>
[src]

Parses the meminfo file.

fn read_hexadecimal_value_with_prefix_u16(&self) -> Result<u16>[src]

Loading content...

Implementors

Loading content...