unixism 0.1.0

A set of tools for working with linux from Rust.
Documentation
  • Coverage
  • 0%
    0 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 16 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 71.88 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kafkiansky

Work with linux from Rust.

Software License Crates.io

Installation

cargo add unixism

Contents

resolv.conf

Parsing an /etc/resolv.conf file.

use unixism::dns;

fn main() {
    let config = dns::resolv::parse_default().unwrap();

    for nameserver in config.nameservers {
        println!("{}", nameserver.to_string());
    }

    for domain in config.search_domains {
        println!("{domain}");
    }

    for option in config.options {
        match option {
            dns::resolv::ConfigOption::Timeout(timeout) => {
                println!("timeout: {timeout}");
            }
            _ => {}
        }
    }
}

Parsing any kind of io::Read type.

use std::fs;
use unixism::dns;

fn main() {
    let config = dns::resolv::parse(fs::File::open("local.conf").unwrap()).unwrap();

    for nameserver in config.nameservers {
        println!("{}", nameserver.to_string());
    }

    for domain in config.search_domains {
        println!("{domain}");
    }

    for option in config.options {
        match option {
            dns::resolv::ConfigOption::Timeout(timeout) => {
                println!("timeout: {timeout}");
            }
            _ => {}
        }
    }
}

hosts

Parsing an /etc/hosts file.

use unixism::hosts;

fn main() {
    for host in hosts::parse_default().unwrap() {
        println!("ip: {}, names: {:#?}", host.ip, host.names);
    }
}

Parsing any kind of io::Read type.

use std::fs;
use unixism::hosts;

fn main() {
    for host in hosts::parse(fs::File::open("local.conf").unwrap()).unwrap() {
        println!("ip: {}, names: {:#?}", host.ip, host.names);
    }
}