DataSource

Trait DataSource 

Source
pub trait DataSource: Send + Sync {
    type State<'a>: Serialize + Deserialize<'a> + Send;
    type ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send;

    // Required methods
    fn schema(&self, diags: &mut Diagnostics) -> Option<Schema>;
    fn read<'a, 'life0, 'life1, 'async_trait>(
        &'life0 self,
        diags: &'life1 mut Diagnostics,
        config: Self::State<'a>,
        provider_meta_state: Self::ProviderMetaState<'a>,
    ) -> Pin<Box<dyn Future<Output = Option<Self::State<'a>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn validate<'a, 'life0, 'life1, 'async_trait>(
        &'life0 self,
        diags: &'life1 mut Diagnostics,
        config: Self::State<'a>,
    ) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for implementing a data source with automatic serialization/deserialization

See also: DynamicDataSource

Required Associated Types§

Source

type State<'a>: Serialize + Deserialize<'a> + Send

State of the data source

The state will be automatically serialized/deserialized at the border of the request.

Source

type ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send

State of the provider metadata

The state will be automatically serialized/deserialized at the border of the request.

Required Methods§

Source

fn schema(&self, diags: &mut Diagnostics) -> Option<Schema>

Get the schema of the data source

§Arguments
  • diags - Diagnostics to record warnings and errors that occured when getting back the schema
§Remarks

The return is ignored if there is an error in diagnostics. If the return is None, an ad-hoc error is added to diagnostics.

Source

fn read<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: Self::State<'a>, provider_meta_state: Self::ProviderMetaState<'a>, ) -> Pin<Box<dyn Future<Output = Option<Self::State<'a>>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read the state of the data source

§Arguments
  • diags - Diagnostics to record warnings and errors that occured during the read
  • config - State as declared in the Terraform file
  • provider_meta_state - State of the provider metadata as declared in the Terraform file
§Remarks

The return is ignored if there is an error in diagnostics. If the return is None, an ad-hoc error is added to diagnostics.

Provided Methods§

Source

fn validate<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: Self::State<'a>, ) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validate the configuration of the data source

§Arguments
  • diags - Diagnostics to record warnings and errors that occured during validation
  • config - State as declared in the Terraform file
§Remarks

The return is ignored if there is an error in diagnostics. If the return is None, an ad-hoc error is added to diagnostics.

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§