Skip to main content

REngineBuilder

Struct REngineBuilder 

Source
pub struct REngineBuilder {
    pub(crate) args: Vec<String>,
    pub(crate) interactive: bool,
    pub(crate) signal_handlers: bool,
    pub(crate) r_home: Option<PathBuf>,
}
Expand description

Builder for configuring and initializing the R runtime.

§Example

let engine = REngine::new()
    .with_args(&["R", "--quiet", "--no-save"])
    .interactive(false)
    .signal_handlers(false)
    .init()?;

Fields§

§args: Vec<String>§interactive: bool§signal_handlers: bool§r_home: Option<PathBuf>

Implementations§

Source§

impl REngineBuilder

Source

pub fn new() -> Self

Create a new R engine builder with default settings.

Source

pub fn with_args(self, args: &[&str]) -> Self

Set the command-line arguments for R initialization.

Default is ["R", "--quiet", "--vanilla"].

Source

pub fn interactive(self, interactive: bool) -> Self

Set whether R should run in interactive mode.

Default is false.

Source

pub fn signal_handlers(self, enable: bool) -> Self

Set whether R should install signal handlers.

Default is false. Set to true if you want R to handle Ctrl+C etc.

Source

pub fn r_home(self, path: impl Into<PathBuf>) -> Self

Set the R_HOME directory explicitly.

By default, R_HOME is auto-detected by running R RHOME or reading the R_HOME environment variable. Use this method to override that behavior with an explicit path.

§Example
let engine = REngine::build()
    .r_home("/opt/R/4.4.0/lib/R")
    .init()
    .expect("Failed to initialize R");
Source

pub unsafe fn init(self) -> Result<REngine, REngineError>

Initialize the R runtime with the configured settings.

§Safety
  • Must only be called once per process
  • Must be called from the main thread
  • R cannot be safely shutdown and reinitialized
§Errors

Returns an error if R initialization fails.

Trait Implementations§

Source§

impl Default for REngineBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 56 bytes