pub struct NixQueryPathMap(pub TreePathMap<NixQueryDrv>);
Expand description
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());
Tuple Fields§
§0: TreePathMap<NixQueryDrv>
Implementations§
Source§impl NixQueryPathMap
impl NixQueryPathMap
pub fn lookup_first(&self, k: &NixQueryDrv) -> Option<&Path>
Trait Implementations§
Source§impl Clone for NixQueryPathMap
impl Clone for NixQueryPathMap
Source§fn clone(&self) -> NixQueryPathMap
fn clone(&self) -> NixQueryPathMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NixQueryPathMap
impl Debug for NixQueryPathMap
Source§impl PartialEq for NixQueryPathMap
impl PartialEq for NixQueryPathMap
impl Eq for NixQueryPathMap
impl StructuralPartialEq for NixQueryPathMap
Auto Trait Implementations§
impl Freeze for NixQueryPathMap
impl RefUnwindSafe for NixQueryPathMap
impl Send for NixQueryPathMap
impl Sync for NixQueryPathMap
impl Unpin for NixQueryPathMap
impl UnwindSafe for NixQueryPathMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more