spin_locked_app/
lib.rs

1//! Spin internal application interfaces
2//!
3//! This crate contains interfaces to Spin application configuration to be used
4//! by crates that implement Spin execution environments: trigger executors and
5//! host components, in particular.
6
7#![deny(missing_docs)]
8
9pub mod locked;
10mod metadata;
11pub mod values;
12
13pub use async_trait::async_trait;
14pub use locked::Variable;
15pub use metadata::{MetadataExt, MetadataKey};
16
17/// MetadataKey for extracting the application name.
18pub const APP_NAME_KEY: MetadataKey = MetadataKey::new("name");
19/// MetadataKey for extracting the application version.
20pub const APP_VERSION_KEY: MetadataKey = MetadataKey::new("version");
21/// MetadataKey for extracting the application description.
22pub const APP_DESCRIPTION_KEY: MetadataKey = MetadataKey::new("description");
23/// MetadataKey for extracting the OCI image digest.
24pub const OCI_IMAGE_DIGEST_KEY: MetadataKey = MetadataKey::new("oci_image_digest");
25
26/// Type alias for a [`Result`]s with [`Error`].
27pub type Result<T> = std::result::Result<T, Error>;
28
29/// Errors returned by methods in this crate.
30#[derive(Debug, thiserror::Error)]
31pub enum Error {
32    /// An error propagated from the `spin_core` crate.
33    #[error(transparent)]
34    CoreError(anyhow::Error),
35    /// An error from a `DynamicHostComponent`.
36    #[error("host component error: {0:#}")]
37    HostComponentError(#[source] anyhow::Error),
38    /// An error from a `Loader` implementation.
39    #[error(transparent)]
40    LoaderError(anyhow::Error),
41    /// An error indicating missing or unexpected metadata.
42    #[error("metadata error: {0}")]
43    MetadataError(String),
44    /// An error indicating failed JSON (de)serialization.
45    #[error("json error: {0}")]
46    JsonError(#[from] serde_json::Error),
47    /// A validation error that can be presented directly to the user.
48    #[error(transparent)]
49    ValidationError(anyhow::Error),
50}