Skip to main content

VTable

Struct VTable 

Source
#[repr(C)]
pub struct VTable {
Show 14 fields pub abi_version: u32, pub num_modules: extern "C" fn() -> usize, pub module_name: extern "C" fn(i: usize, len: *mut usize) -> *const u8, pub create: unsafe extern "C" fn(module: *const u8, len: usize, num_envs: usize, seed: i64) -> *mut c_void, pub destroy: unsafe extern "C" fn(env: *mut c_void), pub describe: unsafe extern "C" fn(env: *const c_void, len: *mut usize) -> *const u8, pub num_envs: unsafe extern "C" fn(env: *const c_void) -> usize, pub num_threads: unsafe extern "C" fn(env: *const c_void) -> usize, pub set_num_threads: unsafe extern "C" fn(env: *mut c_void, threads: usize), pub reset: unsafe extern "C" fn(env: *mut c_void, has_seed: bool, seed: i64), pub obs_into: unsafe extern "C" fn(env: *const c_void, out: *mut f32, len: usize), pub step: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, final_obs: *mut f32, obs_len: usize), pub legal_action_masks: unsafe extern "C" fn(env: *const c_void, out: *mut bool, len: usize) -> bool, pub step_without_final: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, obs_len: usize),
}
Expand description

The functions of a library of compiled vector environments. The environments are opaque pointers made by create and freed by destroy; strings are UTF-8 bytes with their length.

Fields§

§abi_version: u32

ABI_VERSION of the library.

§num_modules: extern "C" fn() -> usize

The number of environments (modules) in the library.

§module_name: extern "C" fn(i: usize, len: *mut usize) -> *const u8

The name of module i, with its length in len.

§create: unsafe extern "C" fn(module: *const u8, len: usize, num_envs: usize, seed: i64) -> *mut c_void

Creates num_envs environments of a module and resets them, or returns null for an unknown module.

§destroy: unsafe extern "C" fn(env: *mut c_void)

Frees environments made by create.

§describe: unsafe extern "C" fn(env: *const c_void, len: *mut usize) -> *const u8

A JSON description of the environments (name, num_actions, obs_shape, action_space), valid while they live.

§num_envs: unsafe extern "C" fn(env: *const c_void) -> usize

The number of environments.

§num_threads: unsafe extern "C" fn(env: *const c_void) -> usize

The number of threads that step them.

§set_num_threads: unsafe extern "C" fn(env: *mut c_void, threads: usize)

Changes the number of threads.

§reset: unsafe extern "C" fn(env: *mut c_void, has_seed: bool, seed: i64)

Starts new episodes (from seed if has_seed).

§obs_into: unsafe extern "C" fn(env: *const c_void, out: *mut f32, len: usize)

Writes the observations (len floats).

§step: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, final_obs: *mut f32, obs_len: usize)

Steps every environment: the actions are kind 0 (discrete, i32), 1 (multi-discrete, i32, dim per environment), or 2 (continuous, f32, dim per environment), len elements at actions; the outputs are num_envs rewards and flags and obs_len floats of observations and final observations.

§legal_action_masks: unsafe extern "C" fn(env: *const c_void, out: *mut bool, len: usize) -> bool

Writes the legal action masks (len flags) and returns true, or returns false if the environment has none.

§step_without_final: unsafe extern "C" fn(env: *mut c_void, kind: u32, actions: *const c_void, len: usize, dim: usize, obs: *mut f32, reward: *mut f32, terminated: *mut bool, truncated: *mut bool, obs_len: usize)

Steps every environment as step does, without the final observations (the environments do not compute them): the outputs are num_envs rewards and flags and obs_len floats of observations.

Trait Implementations§

Source§

impl Debug for VTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.