pub struct Component {Show 16 fields
pub source: ComponentSource,
pub description: String,
pub variables: IndexMap<LowerSnakeId, String>,
pub environment: IndexMap<String, String>,
pub files: Vec<WasiFilesMount>,
pub exclude_files: Vec<String>,
pub allowed_http_hosts: Vec<String>,
pub allowed_outbound_hosts: Vec<String>,
pub key_value_stores: Vec<String>,
pub sqlite_databases: Vec<String>,
pub ai_models: Vec<String>,
pub targets: Option<Vec<TargetEnvironmentRef>>,
pub build: Option<ComponentBuildConfig>,
pub tool: IndexMap<String, Table>,
pub dependencies_inherit_configuration: Option<bool>,
pub dependencies: ComponentDependencies,
/* private fields */
}Expand description
A Spin component.
Fields§
§source: ComponentSourceThe file, package, or URL containing the component Wasm binary.
Example: source = "bin/cart.wasm"
Learn more: https://spinframework.dev/writing-apps#the-component-source
description: StringA human-readable description of the component.
Example: description = "Shopping cart"
variables: IndexMap<LowerSnakeId, String>Configuration variables available to the component. Names must be
in lower_snake_case. Values are strings, and may refer
to application variables using {{ ... }} syntax.
variables = { users_endpoint = "https://{{ api_host }}/users"}
Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications
environment: IndexMap<String, String>Environment variables to be set for the Wasm module.
environment = { DB_URL = "mysql://spin:spin@localhost/dev" }
files: Vec<WasiFilesMount>The files the component is allowed to read. Each list entry is either:
-
a glob pattern (e.g. “assets/**/*.jpg”); or
-
a source-destination pair indicating where a host directory should be mapped in the guest (e.g. { source = “assets”, destination = “/” })
Learn more: https://spinframework.dev/writing-apps#including-files-with-components
exclude_files: Vec<String>Any files or glob patterns that should not be available to the Wasm module at runtime, even though they match a `files`` entry.
Example: exclude_files = ["secrets/*"]
Learn more: https://spinframework.dev/writing-apps#including-files-with-components
allowed_http_hosts: Vec<String>Deprecated. Use allowed_outbound_hosts instead.
Example: allowed_http_hosts = ["example.com"]
allowed_outbound_hosts: Vec<String>The network destinations which the component is allowed to access. Each entry is in the form “(scheme)://(host)[:port]”. Each element allows * as a wildcard e.g. “https://*” (HTTPS on the default port to any destination) or “*://localhost:*” (any protocol to any port on localhost). The host part allows segment wildcards for subdomains e.g. “https://*.example.com”. Application variables are allowed using `{{ my_var }}`` syntax.
Example: allowed_outbound_hosts = ["redis://myredishost.com:6379"]
Learn more: https://spinframework.dev/http-outbound#granting-http-permissions-to-components
key_value_stores: Vec<String>The key-value stores which the component is allowed to access. Stores are identified by label e.g. “default” or “customer”. Stores other than “default” must be mapped to a backing store in the runtime config.
Example: key_value_stores = ["default", "my-store"]
Learn more: https://spinframework.dev/kv-store-api-guide#custom-key-value-stores
sqlite_databases: Vec<String>The SQLite databases which the component is allowed to access. Databases are identified by label e.g. “default” or “analytics”. Databases other than “default” must be mapped to a backing store in the runtime config. Use “spin up –sqlite” to run database setup scripts.
Example: sqlite_databases = ["default", "my-database"]
Learn more: https://spinframework.dev/sqlite-api-guide#preparing-an-sqlite-database
ai_models: Vec<String>The AI models which the component is allowed to access. For local execution, you must download all models; for hosted execution, you should check which models are available in your target environment.
Example: ai_models = ["llama2-chat"]
Learn more: https://spinframework.dev/serverless-ai-api-guide#using-serverless-ai-from-applications
targets: Option<Vec<TargetEnvironmentRef>>The Spin environments with which the component must be compatible. If present, this overrides the default application targets (they are not combined).
Example: targets = ["spin-up:3.3", "spinkube:0.4"]
build: Option<ComponentBuildConfig>The component build configuration.
Learn more: https://spinframework.dev/build
tool: IndexMap<String, Table>Settings for custom tools or plugins. Spin ignores this field.
dependencies_inherit_configuration: Option<bool>If true, dependencies can invoke Spin APIs with the same permissions as the main component. If false, dependencies have no permissions (e.g. network, key-value stores, SQLite databases).
Learn more: https://spinframework.dev/writing-apps#dependency-permissions
dependencies: ComponentDependenciesSpecifies how to satisfy Wasm Component Model imports of this component.
Learn more: https://spinframework.dev/writing-apps#using-component-dependencies
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Component
impl<'de> Deserialize<'de> for Component
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Component
impl JsonSchema for Component
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl !Freeze for Component
impl RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnsafeUnpin for Component
impl UnwindSafe for Component
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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