pub struct ProviderConn { /* private fields */ }Expand description
A connected provider — the protocol-matched client over a dialed channel.
Implementations§
Source§impl ProviderConn
impl ProviderConn
Sourcepub fn new(channel: H2Channel, protocol: PluginProtocol) -> Self
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).
Sourcepub async fn get_schema(&mut self) -> Result<ProviderSchema, ProviderError>
pub async fn get_schema(&mut self) -> Result<ProviderSchema, ProviderError>
GetProviderSchema (v6) / GetSchema (v5) → provider-config +
per-resource implied types.
Sourcepub async fn configure(
&mut self,
config: &DynamicValue,
terraform_version: &str,
) -> Result<(), ProviderError>
pub async fn configure( &mut self, config: &DynamicValue, terraform_version: &str, ) -> Result<(), ProviderError>
ConfigureProvider (v6) / Configure (v5) — provider creds/settings.
Sourcepub async fn plan_resource_change(
&mut self,
type_name: &str,
prior_state: &DynamicValue,
proposed_new_state: &DynamicValue,
config: &DynamicValue,
) -> Result<PlannedChange, ProviderError>
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.
Sourcepub async fn apply_resource_change(
&mut self,
type_name: &str,
prior_state: &DynamicValue,
planned_state: &DynamicValue,
config: &DynamicValue,
) -> Result<DynamicValue, ProviderError>
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.
Sourcepub async fn read_resource(
&mut self,
type_name: &str,
current_state: &DynamicValue,
) -> Result<Option<DynamicValue>, ProviderError>
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.
Sourcepub async fn read_data_source(
&mut self,
type_name: &str,
config: &DynamicValue,
) -> Result<Option<DynamicValue>, ProviderError>
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.
Sourcepub async fn import_resource_state(
&mut self,
type_name: &str,
id: &str,
) -> Result<Option<DynamicValue>, ProviderError>
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.
Sourcepub async fn upgrade_resource_state(
&mut self,
type_name: &str,
stored_version: i64,
raw_json: &[u8],
) -> Result<DynamicValue, ProviderError>
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.
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
${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,
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,
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,
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,
Auto Trait Implementations§
impl !Freeze for ProviderConn
impl !RefUnwindSafe for ProviderConn
impl !UnwindSafe for ProviderConn
impl Send for ProviderConn
impl Sync for ProviderConn
impl Unpin for ProviderConn
impl UnsafeUnpin for ProviderConn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request