pub struct BinFactory {
pub(crate) commands: Commands,
runtime: Arc<dyn Runtime + Send + Sync + 'static>,
pub(crate) local: Arc<RwLock<HashMap<String, Option<Arc<BinaryPackage>>>>>,
}Fields§
§commands: Commands§runtime: Arc<dyn Runtime + Send + Sync + 'static>§local: Arc<RwLock<HashMap<String, Option<Arc<BinaryPackage>>>>>Implementations§
Source§impl BinFactory
impl BinFactory
pub fn new(runtime: Arc<dyn Runtime + Send + Sync + 'static>) -> BinFactory
pub fn runtime(&self) -> &(dyn Runtime + Send + Sync)
Sourcepub fn register_builtin_command<C>(&mut self, cmd: C)
pub fn register_builtin_command<C>(&mut self, cmd: C)
Register a builtin command.
Sourcepub fn register_builtin_command_with_path<C, P>(&mut self, cmd: C, path: P)
pub fn register_builtin_command_with_path<C, P>(&mut self, cmd: C, path: P)
Register a builtin command at a custom path.
Register a builtin command behind an Arc at a custom path.
Sourcepub fn clear_builtin_commands(&mut self)
pub fn clear_builtin_commands(&mut self)
Remove all registered builtin commands.
pub fn set_binary(&self, name: &str, binary: &Arc<BinaryPackage>)
pub async fn get_binary( &self, name: &str, fs: Option<&dyn FileSystem>, ) -> Option<Arc<BinaryPackage>>
Sourcepub fn spawn<'a>(
&'a self,
name: String,
invoked_as: Option<String>,
env: WasiEnv,
) -> Pin<Box<dyn Future<Output = Result<TaskJoinHandle, SpawnError>> + 'a>>
pub fn spawn<'a>( &'a self, name: String, invoked_as: Option<String>, env: WasiEnv, ) -> Pin<Box<dyn Future<Output = Result<TaskJoinHandle, SpawnError>> + 'a>>
invoked_as is the path the guest spelled, for a script that must be
handed to its interpreter under that name rather than the path it
resolved to. None selects the resolved path, which is what a PATH
search produces on Unix.
Every name here is looked up on the filesystem, builtin commands
included. A caller reaches those through Self::try_built_in before
it gets here, and only for the name it started with, so a shebang
naming a builtin interpreter (#!/bin/sh where sh is registered
rather than a file on disk) fails with
SpawnError::BinaryNotFound. Running that interpreter needs the
parent context try_built_in takes, which a spawn already under way
does not hold.
pub fn try_built_in( &self, name: String, parent_ctx: Option<&FunctionEnvMut<'_, WasiEnv>>, builder: &mut Option<WasiEnv>, ) -> Result<TaskJoinHandle, SpawnError>
pub async fn get_executable( &self, name: &str, fs: Option<&dyn FileSystem>, ) -> Option<Executable>
async fn get_executable_for_spawn( &self, name: &str, env: &WasiEnv, ) -> Result<Option<(String, Executable)>, SpawnError>
async fn get_executable_from_wasi_fs( &self, path: &str, env: &WasiEnv, ) -> Result<Option<Executable>, SpawnError>
Trait Implementations§
Source§impl Clone for BinFactory
impl Clone for BinFactory
Source§fn clone(&self) -> BinFactory
fn clone(&self) -> BinFactory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BinFactory
impl !RefUnwindSafe for BinFactory
impl Send for BinFactory
impl Sync for BinFactory
impl Unpin for BinFactory
impl UnsafeUnpin for BinFactory
impl !UnwindSafe for BinFactory
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more