You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: intrinsics.rs
    path of file: ./repos/pants/src/rust/engine/src
    
    the code of the file until where you have to start completion: // Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).

use std::collections::HashMap;
use std::env::current_dir;
use std::path::{Path, PathBuf};
use std::process::Stdio;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

use crate::context::Context;
use crate::externs::fs::{PyAddPrefix, PyFileDigest, PyMergeDigests, PyRemovePrefix};
use crate::nodes::{
    lift_directory_digest, task_side_effected, unmatched_globs_additional_context, DownloadedFile,
    ExecuteProcess, NodeResult, RunId, SessionValues, Snapshot,
};
use crate::python::{throw, Key, Value};
use crate::tasks::Intrinsic;
use crate::types::Types;
use crate::Failure;
use crate::{externs, Core};
use dep_inference::{javascript, python};
use protos::gen::pants::cache::{
    dependency_inference_request, CacheKey, CacheKeyType, DependencyInferenceRequest,
};

use bytes::Bytes;
use dep_inference::javascript::ParsedJavascriptDependencies;
use dep_inference::python::ParsedPythonDependencies;
use futures::future::{BoxFuture, FutureExt, TryFutureExt};
use futures::try_join;
use indexmap::IndexMap;
use pyo3::types::PyString;
use pyo3::{IntoPy, PyAny, PyRef, Python, ToPyObject};
use tokio::process;

use docker::docker::{ImagePullPolicy, ImagePullScope, DOCKER, IMAGE_PULL_CACHE};
use fs::{
    DigestTrie, DirectoryDigest, Entry, GlobMatching, PathStat, RelativePath, SymlinkBehavior,
    TypedPath,
};
use hashing::{Digest, EMPTY_DIGEST};
use process_execution::local::{
    apply_chroot, create_sandbox, prepare_workdir, setup_run_sh_script, KeepSandboxes,
};
use process_execution::{ManagedChild, Platform, ProcessExecutionStrategy};
use rule_graph::{DependencyKey, RuleId};
use stdio::TryCloneAsFile;
use store::{SnapshotOps, Store, SubsetParams};

use crate::externs::dep_inference::PyNativeDependenciesRequest;
use workunit_store::{in_workunit, Level};

use grpc_util::prost::MessageExt;

type IntrinsicFn =
    Box<dyn Fn(Context, Vec<Value>) -> BoxFuture<'static, NodeResult<Value>> + Send + Sync>;

pub struct Intrinsics {
    intrinsics: IndexMap<Intrinsic, IntrinsicFn>,
}

impl Intrinsics {
    pub fn new(types: &Types) -> Intrinsics {
        let mut intrinsics: IndexMap<Intrinsic, IntrinsicFn> = IndexMap::new();
        intrinsics.insert(
            Intrinsic::new(
                "create_digest_to_digest",
                types.directory_digest,
                types.create_digest,
            ),
            Box::new(create_digest_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new(
                "path_globs_to_digest",
                types.directory_digest,
                types.path_globs,
            ),
            Box::new(path_globs_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new("path_globs_to_paths", types.paths, types.path_globs),
            Box::new(path_globs_to_paths),
        );
        intrinsics.insert(
            Intrinsic::new(
                "download_file_to_digest",
                types.directory_digest,
                types.native_download_file,
            ),
            Box::new(download_file_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new("digest_to_snapshot", types.snapshot, types.directory_digest),
            Box::new(digest_to_snapshot),
        );
        intrinsics.insert(
            Intrinsic::new(
                "directory_diges
    
    pub fn new(types: &Types) -> Intrinsics {
        let mut intrinsics: IndexMap<Intrinsic, IntrinsicFn> = IndexMap::new();
        intrinsics.insert(
            Intrinsic::new(
                "create_digest_to_digest",
                types.directory_digest,
                types.create_digest,
            ),
            Box::new(create_digest_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new(
                "path_globs_to_digest",
                types.directory_digest,
                types.path_globs,
            ),
            Box::new(path_globs_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new("path_globs_to_paths", types.paths, types.path_globs),
            Box::new(path_globs_to_paths),
        );
        intrinsics.insert(
            Intrinsic::new(
                "download_file_to_digest",
                types.directory_digest,
                types.native_download_file,
            ),
            Box::new(download_file_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new("digest_to_snapshot", types.snapshot, types.directory_digest),
            Box::new(digest_to_snapshot),
        );
        intrinsics.insert(
            Intrinsic::new(
                "directory_digest_to_digest_contents",
                types.digest_contents,
                types.directory_digest,
            ),
            Box::new(directory_digest_to_digest_contents),
        );
        intrinsics.insert(
            Intrinsic::new(
                "directory_digest_to_digest_entries",
                types.digest_entries,
                types.directory_digest,
            ),
            Box::new(directory_digest_to_digest_entries),
        );
        intrinsics.insert(
            Intrinsic::new(
                "merge_digests_request_to_digest",
                types.directory_digest,
                types.merge_digests,
            ),
            Box::new(merge_digests_request_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new(
                "remove_prefix_request_to_digest",
                types.directory_digest,
                types.remove_prefix,
            ),
            Box::new(remove_prefix_request_to_digest),
        );
        intrinsics.insert(
            Intrinsic::new(
                "add_prefix_request_to_digest",
                types.directory_digest,
                types.add_prefix,
            ),
            Box::new(add_prefix_request_to_digest),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("process_request_to_process_result"),
                product: types.process_result,
                inputs: vec![
                    DependencyKey::new(types.process),
                    DependencyKey::new(types.process_config_from_environment),
                ],
            },
            Box::new(process_request_to_process_result),
        );
        intrinsics.insert(
            Intrinsic::new(
                "digest_subset_to_digest",
                types.directory_digest,
                types.digest_subset,
            ),
            Box::new(digest_subset_to_digest),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("session_values"),
                product: types.session_values,
                inputs: vec![],
            },
            Box::new(session_values),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("run_id"),
                product: types.run_id,
                inputs: vec![],
            },
            Box::new(run_id),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("interactive_process"),
                product: types.interactive_process_result,
                inputs: vec![
                    DependencyKey::new(types.interactive_process),
                    DependencyKey::new(types.process_config_from_environment),
                ],
            },
            Box::new(interactive_process),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("docker_resolve_image"),
                product: types.docker_resolve_image_result,
                inputs: vec![DependencyKey::new(types.docker_resolve_image_request)],
            },
            Box::new(docker_resolve_image),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("parse_python_deps"),
                product: types.parsed_python_deps_result,
                inputs: vec![DependencyKey::new(types.deps_request)],
            },
            Box::new(parse_python_deps),
        );
        intrinsics.insert(
            Intrinsic {
                id: RuleId::new("parse_javascript_deps"),
                product: types.parsed_javascript_deps_result,
                inputs: vec![DependencyKey::new(types.deps_request)],
            },
            Box::new(parse_javascript_deps),
        );
        Intrinsics { intrinsics }
    }