Skip to main content

ResourceDefinition

Trait ResourceDefinition 

Source
pub trait ResourceDefinition:
    Debug
    + Send
    + Sync
    + 'static {
Show 13 methods // Required methods fn get_resource_type(&self) -> ResourceType; fn id(&self) -> &str; fn get_dependencies(&self) -> Vec<ResourceRef>; fn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; fn box_clone(&self) -> Box<dyn ResourceDefinition>; fn resource_eq(&self, other: &dyn ResourceDefinition) -> bool; fn to_json_value(&self) -> Result<Value>; // Provided methods fn get_permissions(&self) -> Option<&str> { ... } fn replace_after_failed_create_is_safe(&self) -> bool { ... } fn with_empty_input_references_removed( &self, _inputs: &InputAnswers<'_>, ) -> Option<Box<dyn ResourceDefinition>> { ... } fn input_references(&self) -> Vec<(&'static str, String)> { ... }
}
Expand description

Trait that defines the interface for all resource types in the Alien system. This trait enables extensibility by allowing new resource types to be registered and managed alongside built-in resources.

Required Methods§

Source

fn get_resource_type(&self) -> ResourceType

Returns the resource type for this instance

Source

fn id(&self) -> &str

Returns the unique identifier for this specific resource instance

Source

fn get_dependencies(&self) -> Vec<ResourceRef>

Returns the list of other resources this resource depends on

Source

fn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>

Validates if an update from the current configuration to a new configuration is allowed

Source

fn as_any(&self) -> &dyn Any

Provides access to the underlying concrete type for downcasting

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Provides mutable access to the underlying concrete type for downcasting

Source

fn box_clone(&self) -> Box<dyn ResourceDefinition>

Creates a boxed clone of this resource definition

Source

fn resource_eq(&self, other: &dyn ResourceDefinition) -> bool

For equality comparison between resource definitions

Source

fn to_json_value(&self) -> Result<Value>

Serialize this resource to a JSON value (without the “type” tag - that’s added by Resource)

Provided Methods§

Source

fn get_permissions(&self) -> Option<&str>

Returns the permission profile name for this resource, if it has one.

Used by ServiceAccountDependenciesMutation to wire the corresponding {profile}-sa service account as a declared dependency so the executor enforces ordering and propagates SA changes automatically.

Override in concrete types that carry a permissions field (Container, Worker).

Source

fn replace_after_failed_create_is_safe(&self) -> bool

Whether the executor may delete this resource and create it again when its create failed and its config changed since.

That replace is unsafe when deleting the half-created resource can destroy something the create already holds: user data (a create can adopt an existing bucket, table or database with the same name, and a key decrypts data stored elsewhere) or live capacity (replicas a timed-out create already started, instances that already launched). Such a resource is created again in place instead. That create may adopt the existing resource by name, or fail on the name until the conflict is resolved by hand, but it never deletes what is there.

Source

fn with_empty_input_references_removed( &self, _inputs: &InputAnswers<'_>, ) -> Option<Box<dyn ResourceDefinition>>

Resolves the fields of this config that point at a deployer stack input.

A config can name an input instead of holding a value (for example the artifact registry’s replicationRegionsInput). The value is known only when a deployment is prepared, so an update that adds such a reference can compare equal to the recorded, reference-free config once the answer is empty. Return None when there is nothing to resolve, or when the resolution cannot be made equal to a config without references (the input is undeclared or answered with a value). Return the config with the references that resolve to “no value” removed when it can. The frozen-resource check uses only that last case, for a recorded config that lacks the reference.

The next input-backed field implements this method instead of special-casing the check.

Source

fn input_references(&self) -> Vec<(&'static str, String)>

The (config field, input id) pairs this config reads from deployer inputs. Names the field in the message when a setup update is needed because an input now has a value.

Trait Implementations§

Source§

impl Clone for Box<dyn ResourceDefinition>

Clone implementation for boxed ResourceDefinition trait objects

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§