[][src]Struct nix_query_tree_viewer::nix_query_tree::NixQueryPathMap

pub struct NixQueryPathMap(pub TreePathMap<NixQueryDrv>);

A mapping of NixQueryDrv to TreePath. This gives an easy way to figure out where a NixQueryDrv is an a NixQueryTree.

use indoc::indoc;
use nix_query_tree_viewer::nix_query_tree::{NixQueryDrv, NixQueryTree};
use nix_query_tree_viewer::tree::Path;
use std::str::FromStr;

let raw_tree = indoc!(
        "/nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10
        +---/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27
        |   +---/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27 [...]
        +---/nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10 [...]
        +---/nix/store/9ny6szla9dg61jv8q22qbnqsz37465n0-multiple-outputs.sh
            +---/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27 [...]
                +---/nix/store/5wvmvcc3b7sisirx1vsqbqdis0sd1x5d-cc-wrapper.sh
                +---/nix/store/5jzbjvnrz85n454inlyxcpgap9i6k6la-pcre-8.43
        "
    );
let nix_query_tree = NixQueryTree::from_str(raw_tree).unwrap();
let map = nix_query_tree.path_map();
let pcre_drv = NixQueryDrv::from("/nix/store/5jzbjvnrz85n454inlyxcpgap9i6k6la-pcre-8.43");
let expected_path = Some(Path::from(vec![2, 0, 1]));

assert_eq!(map.lookup_first(&pcre_drv), expected_path.as_ref());

Methods

impl NixQueryPathMap[src]

pub fn lookup_first(&self, k: &NixQueryDrv) -> Option<&Path>[src]

Trait Implementations

impl Clone for NixQueryPathMap[src]

impl Debug for NixQueryPathMap[src]

impl Eq for NixQueryPathMap[src]

impl PartialEq<NixQueryPathMap> for NixQueryPathMap[src]

impl StructuralEq for NixQueryPathMap[src]

impl StructuralPartialEq for NixQueryPathMap[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.