[][src]Function ift::eval

pub fn eval(s: &str) -> Result<Vec<IpAddr>, Error>

Evaluate a interface template

Given an expression, return a list of IpAddr's that match.

Starting with one producer, use the pipe | character to filter and sort what IpAddr's will be returned. All are quoted with ". One interface can produce multiple IpAddr's. In mac lo0 produces some IPv4 and some IPv6 addresses.

producers

GetAllInterfaces

Get all the interfaces available

GetPrivateInterfaces

Get sorted list of interfaces available that are forwardable, and up. Sorted by default first.

Short for GetAllInterfaces | FilterFlags "up" | SortBy "default"

use ift::eval;
assert_eq!(eval("GetPrivateInterfaces").unwrap(), eval(r#"GetAllInterfaces | FilterFlags "up" | FilterForwardable | SortBy "default""#).unwrap());

GetInterface

Short for GetAllInterfaces | FilterName "name"

use ift::eval;
assert_eq!(eval("GetInterface \"en0\"").unwrap(), eval("GetAllInterfaces | FilterName \"en0\"").unwrap());

filters

Filter the IpAddr's that were produced. If an interface produces multiple IpAddrs then the information about that interface is copied to the other IpAddrs. This means that filters can be on either the interface attributes or the ip attributes along the way.

FilterIPv4

Filter to only ipv4 ips

FilterIPv6

Filter to only ipv6 ips

FilterFlags

Filter by flags "up"/"down"

FilterName

Filter by a specified interface name

FilterForwardable

Filter on whether or not it is forwaradable according to RFC6890

FilterGlobal

Filter on whether or not it is global according to RFC6890

FilterFirst/FilterLast

Only return either the first IpAddr or the last IpAddr

sorts

SortBy

Sort by attribute "default", looks up the default interface and sorts it to the front

use ift::evals;
assert_eq!(true, evals("GetAllInterfaces").is_some());
assert_eq!(false, evals("GetAllInterfaces | FilterIPv4 | FilterIPv6").is_some());