pub struct StackState {
pub platform: Platform,
pub resources: HashMap<String, StackResourceState>,
pub resource_prefix: String,
}Expand description
Represents the collective state of all resources in a stack, including platform and pending actions.
Fields§
§platform: PlatformThe target platform for this stack state.
resources: HashMap<String, StackResourceState>The state of individual resources, keyed by resource ID.
resource_prefix: StringA prefix used for resource naming to ensure uniqueness across deployments.
Implementations§
Source§impl StackState
impl StackState
Sourcepub fn new(platform: Platform) -> Self
pub fn new(platform: Platform) -> Self
Creates a new, empty StackState for a given platform with a generated resource prefix.
Sourcepub fn with_resource_prefix(platform: Platform, resource_prefix: String) -> Self
pub fn with_resource_prefix(platform: Platform, resource_prefix: String) -> Self
Creates an empty StackState for resources whose physical prefix was already chosen by an external setup artifact.
Sourcepub fn resource(&self, id: &str) -> Option<&StackResourceState>
pub fn resource(&self, id: &str) -> Option<&StackResourceState>
Returns a reference to the state of a specific resource if it exists.
Sourcepub fn compute_stack_status(&self) -> Result<StackStatus>
pub fn compute_stack_status(&self) -> Result<StackStatus>
Computes the stack status from the current resource statuses. This is the main function that implements the logic from the TypeScript version.
Sourcepub fn compute_stack_status_from_resources(
resource_statuses: &[ResourceStatus],
) -> Result<StackStatus>
pub fn compute_stack_status_from_resources( resource_statuses: &[ResourceStatus], ) -> Result<StackStatus>
Static method to compute stack status from a list of resource statuses. This method contains the core logic and can be tested independently.
Sourcepub fn get_resource_outputs<T: ResourceOutputsDefinition + 'static>(
&self,
resource_id: &str,
) -> Result<&T>
pub fn get_resource_outputs<T: ResourceOutputsDefinition + 'static>( &self, resource_id: &str, ) -> Result<&T>
Retrieves and downcasts the outputs of a resource from the stack state.
§Arguments
resource_id- The ID of the resource to get outputs for
§Returns
Ok(T)- The downcasted outputs if successfulErr(Error)- If the resource doesn’t exist, has no outputs, or the outputs are not of the expected type
§Example
use alien_core::{StackState, Platform, WorkerOutputs};
let stack_state = StackState::new(Platform::Aws);
// Get worker outputs with error handling
let worker_outputs = stack_state.get_resource_outputs::<WorkerOutputs>("my-worker")?;
if let Some(url) = &worker_outputs.url {
println!("Worker URL: {}", url);
}Trait Implementations§
Source§impl Clone for StackState
impl Clone for StackState
Source§fn clone(&self) -> StackState
fn clone(&self) -> StackState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more