Struct lunatic_process::env::Environment
source · [−]pub struct Environment { /* private fields */ }Implementations
sourceimpl Environment
impl Environment
pub fn new(id: u64) -> Self
pub fn get_process(&self, id: u64) -> Option<Arc<dyn Process>>
pub fn add_process(&self, id: u64, proc: Arc<dyn Process>)
pub fn remove_process(&self, id: u64)
pub fn process_count(&self) -> usize
pub fn send(&self, id: u64, signal: Signal)
pub fn get_next_process_id(&self) -> u64
pub fn id(&self) -> u64
sourceimpl Environment
impl Environment
Spawns a new wasm process from a compiled module.
A Process is created from a module, entry function, array of arguments and config. The
configuration will define some characteristics of the process, such as maximum memory, fuel
and host function properties (filesystem access, networking, ..).
After it’s spawned the process will keep running in the background. A process can be killed
with Signal::Kill signal. If you would like to block until the process is finished you can
.await on the returned JoinHandle<()>.
pub async fn spawn_wasm<S>(
&self,
runtime: WasmtimeRuntime,
module: WasmtimeCompiledModule<S>,
state: S,
function: &str,
params: Vec<Val>,
link: Option<(Option<i64>, Arc<dyn Process>)>
) -> Result<(JoinHandle<Result<S>>, Arc<dyn Process>)> where
S: ProcessState + Send + ResourceLimiter + 'static,
sourceimpl Environment
impl Environment
Spawns a process from a closure.
Example:
let env = lunatic_process::env::Environment::new(1);
let _proc = env.spawn(|_this, mailbox| async move {
// Wait on a message with the tag `27`.
mailbox.pop(Some(&[27])).await;
// TODO: Needs to return ExecutionResult. Probably the `new` function will need to be adjusted
Ok(())
});pub fn spawn<T, F, K, R>(
&self,
func: F
) -> (JoinHandle<Result<T>>, NativeProcess) where
T: Send + 'static,
R: Into<ExecutionResult<T>> + 'static,
K: Future<Output = R> + Send + 'static,
F: FnOnce(NativeProcess, MessageMailbox) -> K,
Trait Implementations
sourceimpl Clone for Environment
impl Clone for Environment
sourcefn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl !UnwindSafe for Environment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more