Title: | Functions to Define R Functions from Inlined Rust Code |
---|---|
Description: | Dynamically define R functions with inlined 'Rust' code. Help is provided to run 'Cargo' <https://doc.rust-lang.org/cargo/> in a manner consistent with CRAN policies in R packages using 'Rust'. The package is not official, affiliated with, nor endorsed by the Rust project. |
Authors: | David B. Dahl [aut, cre] |
Maintainer: | David B. Dahl <[email protected]> |
License: | MIT + file LICENSE | Apache License 2.0 |
Version: | 0.6.0 |
Built: | 2025-02-10 05:29:14 UTC |
Source: | https://github.com/dbdahl/cargo-framework |
This function downloads the ‘rustup’ installer, run it, and adds targets to compile for all the CRAN build machines.
install(force = FALSE)
install(force = FALSE)
force |
If |
Invisibly, TRUE
if successful and FALSE
otherwise.
This function runs Cargo (Rust's package manager) with the ...
arguments passed as command line arguments.
run( ..., minimum_version = ".", search_methods = c("cache", "convention", "path"), leave_no_trace = FALSE, environment_variables = list(), rustflags = NULL, verbose = TRUE, run_twice = FALSE, stdout = "", stderr = "" )
run( ..., minimum_version = ".", search_methods = c("cache", "convention", "path"), leave_no_trace = FALSE, environment_variables = list(), rustflags = NULL, verbose = TRUE, run_twice = FALSE, stdout = "", stderr = "" )
... |
Character vector of command line arguments passed to the
|
minimum_version |
A character string representing the minimum version of
Rust that is needed. Or a path to the root of a package (i.e., the
directory containing the DESCRIPTION file), in which case the value is
found from the field: |
search_methods |
A character vector potentially containing values
|
leave_no_trace |
If |
environment_variables |
A named character vector providing environment
variables which should be temporarily set while running Cargo. Note that
the |
rustflags |
A character vector from which the
|
verbose |
If |
run_twice |
Should the cargo command be run twice? The environment
variable |
stdout |
See argument of the same name in |
stderr |
See argument of the same name in |
The same value and behavior as the base::system2()
function, except
a non-zero exit code will be given in Cargo is not found.
if (run("--version") != 0) { message("Cargo is not installed. Please run cargo::install() in an interactive session.") }
if (run("--version") != 0) { message("Cargo is not installed. Please run cargo::install() in an interactive session.") }
This function takes Rust code as a string from the last unnamed argument, takes variable names for all other unnamed arguments, compiles the Rust function, and wraps it as an R function.
rust_fn( ..., dependencies = character(0), minimum_version = "1.31.0", verbose = FALSE, cached = TRUE, longjmp = TRUE, invisible = FALSE, force = FALSE, which = NULL )
rust_fn( ..., dependencies = character(0), minimum_version = "1.31.0", verbose = FALSE, cached = TRUE, longjmp = TRUE, invisible = FALSE, force = FALSE, which = NULL )
... |
Rust code is taken as a string from the last unnamed argument, and variable names come for all other unnamed arguments. See example. |
dependencies |
A character vector of crate dependencies, e.g.,
|
minimum_version |
A character string representing the minimum version of
Rust that is needed. Or a path to the root of a package (i.e., the
directory containing the DESCRIPTION file), in which case the value is
found from the field: |
verbose |
If |
cached |
Should Cargo use previously downloaded and compiled artifacts? |
longjmp |
Should the compiled function use the faster (but experimental) longjmp functionality when Rust code panics? |
invisible |
Should the compiled function return values invisibly? |
force |
If |
which |
NULL or a vector of length one with name either |
An R function implemented with the supplied Rust code.