Struct spin_app::AppComponent
source · pub struct AppComponent<'a, L = AppLoader> {
pub app: &'a App<'a, L>,
/* private fields */
}
Expand description
An AppComponent
holds configuration for a Spin application component.
Fields§
§app: &'a App<'a, L>
The app this component belongs to.
Implementations§
source§impl<'a, L> AppComponent<'a, L>
impl<'a, L> AppComponent<'a, L>
sourcepub fn source(&self) -> &LockedComponentSource
pub fn source(&self) -> &LockedComponentSource
Returns this component’s Wasm component or module source.
sourcepub fn files(&self) -> Iter<'_, ContentPath>
pub fn files(&self) -> Iter<'_, ContentPath>
Returns an iterator of ContentPath
s for this component’s configured
“directory mounts”.
sourcepub fn get_metadata<T: Deserialize<'a>>(
&self,
key: MetadataKey<T>
) -> Result<Option<T>>
pub fn get_metadata<T: Deserialize<'a>>( &self, key: MetadataKey<T> ) -> Result<Option<T>>
Deserializes typed metadata for this component.
Returns Ok(None)
if there is no metadata for the given key
and an
Err
only if there is a value for the key
but the typed
deserialization failed.
sourcepub fn require_metadata<'this, T: Deserialize<'this>>(
&'this self,
key: MetadataKey<T>
) -> Result<T>
pub fn require_metadata<'this, T: Deserialize<'this>>( &'this self, key: MetadataKey<T> ) -> Result<T>
Deserializes typed metadata for this component.
Like AppComponent::get_metadata
, but returns an error if there is
no metadata for the given key
.
source§impl<'a> AppComponent<'a>
impl<'a> AppComponent<'a>
sourcepub async fn load_component<T: Send + Sync>(
&self,
engine: &Engine<T>
) -> Result<Component>
pub async fn load_component<T: Send + Sync>( &self, engine: &Engine<T> ) -> Result<Component>
Loads and returns the [spin_core::Component
] for this component.
sourcepub async fn load_module<T: Send + Sync>(
&self,
engine: &Engine<T>
) -> Result<Module>
pub async fn load_module<T: Send + Sync>( &self, engine: &Engine<T> ) -> Result<Module>
Loads and returns the [spin_core::Module
] for this component.
sourcepub async fn apply_store_config(&self, builder: &mut StoreBuilder) -> Result<()>
pub async fn apply_store_config(&self, builder: &mut StoreBuilder) -> Result<()>
Updates the given StoreBuilder
with configuration for this component.
In particular, the WASI ‘env’ and “preloaded dirs” are set up, and any
DynamicHostComponent
s associated with the source AppLoader
are
configured.
Auto Trait Implementations§
impl<'a, L> RefUnwindSafe for AppComponent<'a, L>where
L: RefUnwindSafe,
impl<'a, L> Send for AppComponent<'a, L>where
L: Sync,
impl<'a, L> Sync for AppComponent<'a, L>where
L: Sync,
impl<'a, L> Unpin for AppComponent<'a, L>
impl<'a, L> UnwindSafe for AppComponent<'a, L>where
L: RefUnwindSafe,
Blanket Implementations§
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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.