Skip to main content

ProviderSchema

Struct ProviderSchema 

Source
pub struct ProviderSchema {
    pub provider_config: CtyType,
    pub resources: BTreeMap<String, CtyType>,
    pub data_sources: BTreeMap<String, CtyType>,
    pub resource_versions: BTreeMap<String, i64>,
}
Expand description

A provider’s schema reduced to the implied cty types the apply codec needs: the provider-config type + each managed resource’s type.

Fields§

§provider_config: CtyType§resources: BTreeMap<String, CtyType>§data_sources: BTreeMap<String, CtyType>

Data-source implied types (data.<type>), needed to encode a ReadDataSource config + decode its result. Without these the apply engine cannot evaluate ${data.*} references (the rio-drive leak).

§resource_versions: BTreeMap<String, i64>

Each managed resource type’s CURRENT schema version, as declared by the provider’s GetProviderSchema/GetSchema response (the Schema.version field sibling to the Schema.block that crate::schema::block_implied_type turns into resources’ implied types). The terraform plugin protocol requires UpgradeResourceState to run whenever a stored StateInstance’s schema_version is older than this — otherwise its raw attribute JSON (persisted under the OLD schema) gets decoded straight against the NEW implied type, which a schema change can silently misinterpret or fail to marshal. See ProviderConn::upgrade_resource_state + ProviderSchema::resource_version.

Implementations§

Source§

impl ProviderSchema

Source

pub fn resource(&self, type_name: &str) -> Option<&CtyType>

Source

pub fn data_source(&self, type_name: &str) -> Option<&CtyType>

Source

pub fn resource_version(&self, type_name: &str) -> i64

The provider’s CURRENT schema version for type_name. 0 both for a genuinely version-0 schema AND for a type the provider never declared — matching Terraform’s own convention that an un-versioned schema is version 0, so an unknown type never looks artificially “newer” than a stored instance and never triggers a spurious upgrade.

Source

pub fn resource_version_u64(&self, type_name: &str) -> u64

Self::resource_version clamped into magma_types::StateInstance’s u64 schema_version field. Real provider schema versions are always small non-negative integers in practice; this only differs from the wire i64 for a malformed negative version (never observed from a real provider), which clamps to 0 rather than wrapping to a huge u64.

Trait Implementations§

Source§

impl Clone for ProviderSchema

Source§

fn clone(&self) -> ProviderSchema

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
Source§

impl Debug for ProviderSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.