pub trait ResourceDefinition:
Debug
+ Send
+ Sync
+ 'static {
// 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 { ... }
}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§
Sourcefn get_resource_type(&self) -> ResourceType
fn get_resource_type(&self) -> ResourceType
Returns the resource type for this instance
Sourcefn get_dependencies(&self) -> Vec<ResourceRef>
fn get_dependencies(&self) -> Vec<ResourceRef>
Returns the list of other resources this resource depends on
Sourcefn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>
fn validate_update(&self, new_config: &dyn ResourceDefinition) -> Result<()>
Validates if an update from the current configuration to a new configuration is allowed
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Provides mutable access to the underlying concrete type for downcasting
Sourcefn box_clone(&self) -> Box<dyn ResourceDefinition>
fn box_clone(&self) -> Box<dyn ResourceDefinition>
Creates a boxed clone of this resource definition
Sourcefn resource_eq(&self, other: &dyn ResourceDefinition) -> bool
fn resource_eq(&self, other: &dyn ResourceDefinition) -> bool
For equality comparison between resource definitions
Sourcefn to_json_value(&self) -> Result<Value>
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§
Sourcefn get_permissions(&self) -> Option<&str>
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).
Sourcefn replace_after_failed_create_is_safe(&self) -> bool
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.
Trait Implementations§
Source§impl Clone for Box<dyn ResourceDefinition>
Clone implementation for boxed ResourceDefinition trait objects
impl Clone for Box<dyn ResourceDefinition>
Clone implementation for boxed ResourceDefinition trait objects
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".