Skip to main content

ProviderConn

Struct ProviderConn 

Source
pub struct ProviderConn { /* private fields */ }
Expand description

A connected provider — the protocol-matched client over a dialed channel.

Implementations§

Source§

impl ProviderConn

Source

pub fn new(channel: H2Channel, protocol: PluginProtocol) -> Self

Wrap a dialed channel, selecting the client by the handshake’s negotiated protocol (Plugin::handshake().app_protocol).

Source

pub async fn get_schema(&mut self) -> Result<ProviderSchema, ProviderError>

GetProviderSchema (v6) / GetSchema (v5) → provider-config + per-resource implied types.

Source

pub async fn configure( &mut self, config: &DynamicValue, terraform_version: &str, ) -> Result<(), ProviderError>

ConfigureProvider (v6) / Configure (v5) — provider creds/settings.

Source

pub async fn plan_resource_change( &mut self, type_name: &str, prior_state: &DynamicValue, proposed_new_state: &DynamicValue, config: &DynamicValue, ) -> Result<PlannedChange, ProviderError>

PlanResourceChange — the provider’s proposed new state PLUS which attribute paths (if any) force a destroy+create instead of an in-place update. See PlannedChange’s doc for why the latter matters: it is the ONLY authoritative source for that decision, and was silently discarded here before PlannedChange existed.

Source

pub async fn apply_resource_change( &mut self, type_name: &str, prior_state: &DynamicValue, planned_state: &DynamicValue, config: &DynamicValue, ) -> Result<DynamicValue, ProviderError>

ApplyResourceChange — execute the change. Returns the new state.

Source

pub async fn read_resource( &mut self, type_name: &str, current_state: &DynamicValue, ) -> Result<Option<DynamicValue>, ProviderError>

ReadResource — read the resource’s ACTUAL current state from the provider (the refresh primitive). Returns Ok(None) when the provider reports the resource no longer exists (new_state is cty-null), so callers drop stale / phantom entries from state; Ok(Some(dv)) with the refreshed wire state when it still exists.

Source

pub async fn read_data_source( &mut self, type_name: &str, config: &DynamicValue, ) -> Result<Option<DynamicValue>, ProviderError>

ReadDataSource — evaluate a data block by querying the provider, returning its result state. The apply engine reads data sources up front so ${data.<type>.<name>.<attr>} references resolve; without it those strings leaked verbatim to managed-resource RPCs (the rio-drive Cloudflare 400). Ok(None) if the provider returned cty-null.

Source

pub async fn import_resource_state( &mut self, type_name: &str, id: &str, ) -> Result<Option<DynamicValue>, ProviderError>

ImportResourceState — adopt a resource that EXISTS in the cloud but is absent from magma’s state, by its provider-native import id (e.g. the repo name for github_repository). Returns the imported wire state (Ok(Some(dv))) or Ok(None) if the provider imported nothing / returned cty-null. This is the read/import half of the protocol that powers import-on-create-conflict (422 already-exists → observe → adopt)

  • magma import. Mirrors apply/read’s V5/V6 dispatch + msgpack decode.
Source

pub async fn upgrade_resource_state( &mut self, type_name: &str, stored_version: i64, raw_json: &[u8], ) -> Result<DynamicValue, ProviderError>

UpgradeResourceState — migrate a StateInstance’s raw attribute JSON (persisted under an older stored_version of the provider’s schema for type_name) forward to the CURRENT schema. The terraform plugin protocol requires this to run before a stored instance is fed into ReadResource/PlanResourceChange/ ApplyResourceChange whenever stored_version is older than the provider’s live ProviderSchema::resource_version — decoding old-schema JSON straight against the new implied type (skipping this call) risks a marshal mismatch or provider-side crash/misparse on any resource type whose schema evolved. raw_json is the instance’s raw attribute bytes as stored (magma persists state attributes as JSON, never the legacy flatmap format, so only RawState.json is populated). Returns the upgraded value, decodable via DynamicValue::to_json against the CURRENT implied type.

Trait Implementations§

Source§

impl Provider for ProviderConn

The gRPC/tfplugin implementation of the provider contract.

Pure delegation to the inherent methods above — this adds no behaviour, it only makes the EXISTING transport one implementation of a contract rather than the only thing an engine can hold.

── ★ WHY EVERY BODY IS FULLY QUALIFIED ────────────────────────────── ProviderConn::get_schema(self), not self.get_schema(). Both resolve to the inherent method — inherent wins over trait — so the short form compiles and works today. But it is one refactor away from disaster: delete or rename the inherent method and self.get_schema() silently rebinds to the TRAIT method, which is this function, and the result is unbounded recursion at runtime rather than an error at compile time. The qualified form cannot rebind: if the inherent method stops existing, this stops compiling.

Source§

fn get_schema<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<ProviderSchema, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The provider’s schema, reduced to implied cty types.
Source§

fn configure<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, config: &'life1 DynamicValue, terraform_version: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provider credentials / settings. See the ordering note above.
Source§

fn plan_resource_change<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, type_name: &'life1 str, prior_state: &'life2 DynamicValue, proposed_new_state: &'life3 DynamicValue, config: &'life4 DynamicValue, ) -> Pin<Box<dyn Future<Output = Result<PlannedChange, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

The provider’s proposed new state PLUS its requires_replace verdict — the only authoritative source for replace-vs-update.
Source§

fn apply_resource_change<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, type_name: &'life1 str, prior_state: &'life2 DynamicValue, planned_state: &'life3 DynamicValue, config: &'life4 DynamicValue, ) -> Pin<Box<dyn Future<Output = Result<DynamicValue, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Execute the change; returns the new state. Read more
Source§

fn read_resource<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, type_name: &'life1 str, current_state: &'life2 DynamicValue, ) -> Pin<Box<dyn Future<Output = Result<Option<DynamicValue>, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Refresh. Ok(None) means the resource no longer exists, so the caller drops it from state — distinct from an error.
Source§

fn read_data_source<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, type_name: &'life1 str, config: &'life2 DynamicValue, ) -> Pin<Box<dyn Future<Output = Result<Option<DynamicValue>, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Read a data source, so ${data.<type>.<name>.<attr>} resolves.
Source§

fn import_resource_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, type_name: &'life1 str, id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DynamicValue>, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Adopt an existing resource by id — the import half that powers import-on-create-conflict and magma import.
Source§

fn upgrade_resource_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, type_name: &'life1 str, stored_version: i64, raw_json: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<DynamicValue, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Migrate stored attribute JSON written under an older schema version up to the current one.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more