Skip to main content

Crate runfiles

Crate runfiles 

Source
Expand description

Runfiles lookup library for Bazel-built Rust binaries and tests.

USAGE:

  1. Depend on this runfiles library from your build rule:
rust_binary(
    name = "my_binary",
    ...
    data = ["//path/to/my/data.txt"],
    deps = ["@rules_rust//rust/runfiles"],
)
  1. Import the runfiles library.
ⓘ
use runfiles::Runfiles;
  1. Create a Runfiles object and use `rlocation!`` to look up runfile paths:
ⓘ

use runfiles::{Runfiles, rlocation};

let r = Runfiles::create().unwrap();
let path = rlocation!(r, "my_workspace/path/to/my/data.txt").expect("Failed to locate runfile");

let f = File::open(path).unwrap();

// ...

Macros§

rlocation

Structs§

Runfiles
An interface for accessing to Bazel runfiles.
RunfilesBuilder
Builder for Runfiles. Construct via Runfiles::builder.

Enums§

RunfilesError
The error type for Runfiles construction.

Functions§

find_runfiles_dir
Returns the .runfiles directory for the currently executing binary.

Type Aliases§

Result
A specialized std::result::Result type for