pub struct App { /* private fields */ }
Expand description
An App
holds loaded configuration for a Spin application.
Implementations§
Source§impl App
impl App
Sourcepub fn new(id: impl Into<String>, locked: LockedApp) -> Self
pub fn new(id: impl Into<String>, locked: LockedApp) -> Self
Returns a new app for the given runtime-specific identifier and locked app.
Sourcepub fn get_metadata<'this, T: Deserialize<'this>>(
&'this self,
key: MetadataKey<T>,
) -> Result<Option<T>>
pub fn get_metadata<'this, T: Deserialize<'this>>( &'this self, key: MetadataKey<T>, ) -> Result<Option<T>>
Deserializes typed metadata for this app.
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 app.
Like App::get_metadata
, but returns an error if there is
no metadata for the given key
.
Sourcepub fn variables(&self) -> impl Iterator<Item = (&String, &Variable)>
pub fn variables(&self) -> impl Iterator<Item = (&String, &Variable)>
Returns an iterator of custom config Variable
s defined for this app.
Sourcepub fn components(&self) -> impl Iterator<Item = AppComponent<'_>>
pub fn components(&self) -> impl Iterator<Item = AppComponent<'_>>
Returns an iterator of AppComponent
s defined for this app.
Sourcepub fn get_component(&self, component_id: &str) -> Option<AppComponent<'_>>
pub fn get_component(&self, component_id: &str) -> Option<AppComponent<'_>>
Returns the AppComponent
with the given component_id
, or None
if it doesn’t exist.
Sourcepub fn triggers(&self) -> impl Iterator<Item = AppTrigger<'_>> + '_
pub fn triggers(&self) -> impl Iterator<Item = AppTrigger<'_>> + '_
Returns an iterator of AppTrigger
s defined for this app.
Sourcepub fn get_trigger_metadata<'this, T: Deserialize<'this>>(
&'this self,
trigger_type: &str,
) -> Result<Option<T>>
pub fn get_trigger_metadata<'this, T: Deserialize<'this>>( &'this self, trigger_type: &str, ) -> Result<Option<T>>
Returns the trigger metadata for a specific trigger type.
Sourcepub fn triggers_with_type<'a>(
&'a self,
trigger_type: &'a str,
) -> impl Iterator<Item = AppTrigger<'_>>
pub fn triggers_with_type<'a>( &'a self, trigger_type: &'a str, ) -> impl Iterator<Item = AppTrigger<'_>>
Returns an iterator of AppTrigger
s defined for this app with
the given trigger_type
.
Sourcepub fn trigger_configs<'a, T: Deserialize<'a>>(
&'a self,
trigger_type: &'a str,
) -> Result<impl IntoIterator<Item = (&'a str, T)>>
pub fn trigger_configs<'a, T: Deserialize<'a>>( &'a self, trigger_type: &'a str, ) -> Result<impl IntoIterator<Item = (&'a str, T)>>
Returns an iterator of trigger IDs and deserialized trigger configs for
the given trigger_type
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for App
impl RefUnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnwindSafe for App
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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