Resource

Trait Resource 

Source
pub trait Resource:
    Debug
    + Clone
    + PartialEq
    + HasDependencies
    + Serialize
    + DeserializeOwned
    + 'static {
    type Provider;
    type Error: UserError;
    type Output: Debug + Clone + PartialEq + Serialize + DeserializeOwned + 'static;

    // Provided methods
    fn create(
        &self,
        _provider: &Self::Provider,
    ) -> impl Future<Output = Result<Self::Output, Self::Error>> { ... }
    fn read(
        &self,
        _provider: &Self::Provider,
    ) -> impl Future<Output = Result<Self::Output, Self::Error>> { ... }
    fn update(
        &self,
        _provider: &Self::Provider,
        _previous_local: &Self,
        _previous_remote: &Self::Output,
    ) -> impl Future<Output = Result<Self::Output, Self::Error>> { ... }
    fn delete(
        &self,
        _provider: &Self::Provider,
        _previous_remote: &Self::Output,
    ) -> impl Future<Output = Result<(), Self::Error>> { ... }
}
Expand description

IaC resources.

Represents a resource created on a platform (ie AWS, Digital Ocean, etc).

Required Associated Types§

Source

type Provider

Type of the platform/resource provider.

For example aws_config::SdkConfig in the case of amazon web services.

Source

type Error: UserError

Errors that may occur interacting with the provider.

Source

type Output: Debug + Clone + PartialEq + Serialize + DeserializeOwned + 'static

The remote type of this resource, which we can used to fill in Remote values in other resources.

Provided Methods§

Source

fn create( &self, _provider: &Self::Provider, ) -> impl Future<Output = Result<Self::Output, Self::Error>>

Creates a new resource on the platform.

This method should be implemented to define how a resource is created using the provider’s API. It returns a future that resolves to the resource’s output type or an error.

§Note

This method is explicitly unimplemented! for developer convenience. It allows you to define only the methods you need. However, take care when using this in contexts like long-running daemons, as calling an unimplemented method will cause a panic.

Source

fn read( &self, _provider: &Self::Provider, ) -> impl Future<Output = Result<Self::Output, Self::Error>>

Reads the current state of the resource from the platform.

This method should be implemented to define how to fetch the current state of a resource using the provider’s API. It returns a future that resolves to the resource’s output type or an error.

§Note

This method is explicitly unimplemented! for developer convenience. It allows you to define only the methods you need. However, take care when using this in contexts like long-running daemons, as calling an unimplemented method will cause a panic.

Source

fn update( &self, _provider: &Self::Provider, _previous_local: &Self, _previous_remote: &Self::Output, ) -> impl Future<Output = Result<Self::Output, Self::Error>>

Updates an existing resource on the platform.

This method should be implemented to define how a resource is updated using the provider’s API. It takes the previous local and remote states of the resource and returns a future that resolves to the updated resource’s output type or an error.

§Note

This method is explicitly unimplemented! for developer convenience. It allows you to define only the methods you need. However, take care when using this in contexts like long-running daemons, as calling an unimplemented method will cause a panic.

Source

fn delete( &self, _provider: &Self::Provider, _previous_remote: &Self::Output, ) -> impl Future<Output = Result<(), Self::Error>>

Deletes a resource from the platform.

This method should be implemented to define how a resource is deleted using the provider’s API. It takes the previous remote state of the resource and returns a future that resolves to a unit type or an error.

§Note

This method is explicitly unimplemented! for developer convenience. It allows you to define only the methods you need. However, take care when using this in contexts like long-running daemons, as calling an unimplemented method will cause a panic.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§