### Construct an AttributePath Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.AttributePath.html Example showing how to chain methods to build a complex attribute path. ```rust let path = AttributePath::new("foo").key("bar").attribute("array").index(1); // foo["bar"].array[1] ``` -------------------------------- ### serve Source: https://docs.rs/tf-provider Starts the provider server using a type that implements the Provider trait with automatic serialization/deserialization. ```APIDOC ## serve ### Description Starts the provider server. This function is used to serve a provider implementation that utilizes automatic serialization and deserialization. ### Signature `pub fn serve()` ### Parameters - **P** (Trait) - A type that implements the `Provider` trait. ``` -------------------------------- ### Implement Optional NestedBlock Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/enum.NestedBlock.html Example of implementing an optional nested block using value::serde_as_vec. ```rust use tf_provider::value::{self, Value}; #[derive(Serialize, Deserialize)] struct MyBlock { /* ... */ } #[derive(Serialize, Deserialize)] struct MyState { #[serde(with = "value::serde_as_vec")] my_block: Value, } ``` -------------------------------- ### serve Source: https://docs.rs/tf-provider/0.2.2/tf_provider/all.html Initializes and runs the provider server. ```APIDOC ## serve ### Description Starts the provider server using the provided implementation. ### Signature `pub fn serve()` ``` -------------------------------- ### serve_dynamic Source: https://docs.rs/tf-provider/0.2.2/tf_provider/all.html Initializes and runs a dynamic provider server. ```APIDOC ## serve_dynamic ### Description Starts the dynamic provider server using the provided dynamic implementation. ### Signature `pub fn serve_dynamic()` ``` -------------------------------- ### pub async fn serve(name: U, provider: V) -> Result<()> Source: https://docs.rs/tf-provider/0.2.2/tf_provider/fn.serve.html Serves the specified provider under the given name. ```APIDOC ## serve ### Description Serves the provider. Note that it is not safe to cancel the output future. ### Signature `pub async fn serve(name: U, provider: V) -> Result<()>` ### Arguments - **name** (U: ToString) - Name of the provider to serve. - **provider** (V: DynamicProvider) - Provider to be served. ### See Also - `serve_dynamic` ``` -------------------------------- ### Initialize a HashMap with map macro Source: https://docs.rs/tf-provider/0.2.2/tf_provider/macro.map.html Use the map macro to create a HashMap. Type annotations are typically required due to the use of Into::into. ```rust let m: HashMap = map!{ "key1" => "value1", "key2" => "value2", }; ``` -------------------------------- ### pub async fn serve_dynamic Source: https://docs.rs/tf-provider/0.2.2/tf_provider/fn.serve_dynamic.html Serves a dynamic provider with the specified name. ```APIDOC ## serve_dynamic ### Description Serve the provider. ### Signature `pub async fn serve_dynamic(name: String, provider: Box) -> Result<()>` ### Arguments - **name** (String) - Name of the provider to serve - **provider** (Box) - Provider to be served ### Cancel Safety It is not safe to cancel the output future. ``` -------------------------------- ### CloneToUninit implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Experimental nightly-only API for performing copy-assignment from self to a destination pointer. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Description::plain Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Description.html Creates a new Description instance with the kind set to Plain. ```APIDOC ## pub fn plain(content: T) -> Self ### Description Creates a plain description. ### Arguments - **content** (T: ToString) - The content of the description. ``` -------------------------------- ### Diagnostic::short Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Creates a diagnostic with a summary and attribute path, but no details. ```APIDOC ## Diagnostic::short(summary, attribute) ### Description Creates a diagnostic without details. ### Parameters - **summary** (S: Into>) - Required - Summary of the diagnostic component - **attribute** (AttributePath) - Required - Attribute path for the diagnostic component ``` -------------------------------- ### Diagnostic::root_short Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Creates a simple diagnostic without an AttributePath or details. ```APIDOC ## Diagnostic::root_short(summary) ### Description Creates a diagnostic without AttributePath nor details. ### Parameters - **summary** (S: Into>) - Required - Summary of the diagnostic component ``` -------------------------------- ### Diagnostic::new Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Creates a new Diagnostic instance with a summary, detail, and attribute path. ```APIDOC ## Diagnostic::new(summary, detail, attribute) ### Description Creates a new diagnostic instance with a summary, detail, and attribute path. ### Parameters - **summary** (S: Into>) - Required - Summary of the diagnostic component - **detail** (D: Into>) - Required - Detail of the diagnostic component - **attribute** (AttributePath) - Required - Attribute path for the diagnostic component ``` -------------------------------- ### Diagnostic Constructor Methods Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Various methods to instantiate a Diagnostic object based on the required level of detail and context. ```rust pub fn new>, D: Into>>( summary: S, detail: D, attribute: AttributePath, ) -> Self ``` ```rust pub fn function>>(index: i64, message: S) -> Self ``` ```rust pub fn root>, D: Into>>( summary: S, detail: D, ) -> Self ``` ```rust pub fn short>>( summary: S, attribute: AttributePath, ) -> Self ``` ```rust pub fn root_short>>(summary: S) -> Self ``` -------------------------------- ### Implement schema method Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicFunction.html Method to retrieve the function schema, with diagnostics used for error reporting. ```rust fn schema(&self, diags: &mut Diagnostics) -> Option ``` -------------------------------- ### Description::markdown Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Description.html Creates a new Description instance with the kind set to Markdown. ```APIDOC ## pub fn markdown(content: T) -> Self ### Description Creates a markdown description. ### Arguments - **content** (T: ToString) - The content of the description. ``` -------------------------------- ### Import existing resource Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Imports a resource using an opaque ID. Must return Some even if errors occur during the import process. ```rust fn import<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, id: String, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, ``` -------------------------------- ### fn upgrade Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Upgrades a resource from a prior state version to the current version. ```APIDOC ## fn upgrade(&self, diags: &mut Diagnostics, version: i64, prior_state: RawValue) ### Description Upgrade the resource. If the return is None, an ad-hoc error is added to diagnostics, and the resource state is kept unchanged. ### Parameters - **diags** (Diagnostics) - Required - Diagnostics to record warnings and errors that occurred during the import. - **version** (i64) - Required - Prior version of the resource to upgrade as recorded in Terraform state. - **prior_state** (RawValue) - Required - Prior state of the resource to upgrade as recorded in Terraform state. ``` -------------------------------- ### fn import Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Imports an existing resource using an opaque identifier. Returns the imported state and associated data. ```APIDOC ## fn import(&self, diags: &mut Diagnostics, id: String) ### Description Import an existing resource. If the return is None, an ad-hoc error is added to diagnostics. ### Parameters - **diags** (Diagnostics) - Required - Diagnostics to record warnings and errors that occurred during the import. - **id** (String) - Required - Opaque string that the provider can use to identify the actual resource to import. ``` -------------------------------- ### Function signature for serve Source: https://docs.rs/tf-provider/0.2.2/tf_provider/fn.serve.html The function signature for serving a provider, which is not cancel-safe. ```rust pub async fn serve( name: U, provider: V, ) -> Result<()> ``` -------------------------------- ### take(&mut self) -> Self Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueEmpty.html Takes the value out of the instance, leaving a Value::Null in its place. ```APIDOC ## pub fn take(&mut self) -> Self ### Description Takes the value out, leaving a `Value::Null` in its place. ``` -------------------------------- ### serve_dynamic function signature Source: https://docs.rs/tf-provider/0.2.2/tf_provider/fn.serve_dynamic.html The function signature for serving a dynamic provider. ```rust pub async fn serve_dynamic( name: String, provider: Box, ) -> Result<()> ``` -------------------------------- ### as_ref_option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Transforms the &Value into an Option<&T>, mapping Value::Value(v) to Some(v), and both Value::Null and Value::Unknown to None. ```APIDOC ## pub fn as_ref_option(&self) -> Option<&T> ### Description Transforms the `&Value` into a `Option<&T>`, mapping `Value::Value(v)` to `Some(v)`, `Value::Null` to `None`, and `Value::Unknown` to `None`. ``` -------------------------------- ### Validate resource configuration Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Validates the resource configuration and records diagnostics. Returns None if validation fails, triggering an ad-hoc error. ```rust fn validate<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, ``` -------------------------------- ### as_option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Transforms the Value into an Option, mapping Value::Value(v) to Some(v), and both Value::Null and Value::Unknown to None. ```APIDOC ## pub fn as_option(self) -> Option ### Description Transforms the `Value` into a `Option`, mapping `Value::Value(v)` to `Some(v)`, `Value::Null` to `None`, and `Value::Unknown` to `None`. ``` -------------------------------- ### From trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Returns the argument unchanged. ```rust fn from(t: T) -> T ``` -------------------------------- ### Diagnostic::root Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Creates a diagnostic without an associated AttributePath. ```APIDOC ## Diagnostic::root(summary, detail) ### Description Creates a diagnostic without AttributePath. ### Parameters - **summary** (S: Into>) - Required - Summary of the diagnostic component - **detail** (D: Into>) - Required - Detail of the diagnostic component ``` -------------------------------- ### Resource Trait Methods Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.Resource.html Asynchronous methods for resource lifecycle management including validation, importing, and state upgrades. ```rust fn validate<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: Self::State<'a>, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn import<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, id: String, ) -> Pin, Self::PrivateState<'a>)>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn upgrade<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, version: i64, prior_state: RawValue, ) -> Pin>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } ``` -------------------------------- ### Logical AND operation on Value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Demonstrates the eager evaluation of the and method, which returns the second value if the first is a concrete value. ```rust let x = Value::Value(2); let y: Value<&str> = Value::Null; assert_eq!(x.and(y), Value::Null); let x = Value::Value(2); let y: Value<&str> = Value::Unknown; assert_eq!(x.and(y), Value::Unknown); let x: Value = Value::Null; let y = Value::Value("foo"); assert_eq!(x.and(y), Value::Null); let x: Value = Value::Unknown; let y = Value::Value("foo"); assert_eq!(x.and(y), Value::Unknown); let x = Value::Value(2); let y = Value::Value("foo"); assert_eq!(x.and(y), Value::Value("foo")); let x: Value = Value::Null; let y: Value<&str> = Value::Null; assert_eq!(x.and(y), Value::Null); let x: Value = Value::Null; let y: Value<&str> = Value::Unknown; assert_eq!(x.and(y), Value::Null); let x: Value = Value::Unknown; let y: Value<&str> = Value::Null; assert_eq!(x.and(y), Value::Unknown); let x: Value = Value::Unknown; let y: Value<&str> = Value::Unknown; assert_eq!(x.and(y), Value::Unknown); ``` -------------------------------- ### replace(&mut self, val: T) -> Self Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueEmpty.html Replaces the actual value with the provided value, returning the old value. ```APIDOC ## pub fn replace(&mut self, val: T) -> Self ### Description Replaces the actual value by the value given in parameter, returning the old value if present, leaving a `Value::Null` in its place without deinitializing either one. ### Parameters - **val** (T) - Required - The new value to store. ``` -------------------------------- ### Use replace to swap values Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Replaces the current value with a new one and returns the previous value. ```rust let mut x = Value::Value(2); let old = x.replace(5); assert_eq!(x, Value::Value(5)); assert_eq!(old, Value::Value(2)); let mut x = Value::Null; let old = x.replace(3); assert_eq!(x, Value::Value(3)); assert_eq!(old, Value::Null); let mut x = Value::Unknown; let old = x.replace(3); assert_eq!(x, Value::Value(3)); assert_eq!(old, Value::Unknown); ``` -------------------------------- ### Implement call method Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicFunction.html Method to execute the function logic asynchronously, returning a pinned future. ```rust fn call<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, params: Vec, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, ``` -------------------------------- ### Logical OR operation on Value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Demonstrates the eager evaluation of the or method, which returns the first value if it is present or unknown. ```rust let x = Value::Value(2); let y = Value::Null; assert_eq!(x.or(y), Value::Value(2)); let x = Value::Value(2); let y = Value::Unknown; assert_eq!(x.or(y), Value::Value(2)); let x = Value::Value(2); let y = Value::Value(100); assert_eq!(x.or(y), Value::Value(2)); let x = Value::Null; let y = Value::Value(100); assert_eq!(x.or(y), Value::Value(100)); let x: Value = Value::Null; let y = Value::Null; assert_eq!(x.or(y), Value::Null); let x: Value = Value::Null; let y = Value::Unknown; assert_eq!(x.or(y), Value::Unknown); let x = Value::Unknown; let y = Value::Value(100); assert_eq!(x.or(y), Value::Unknown); let x: Value = Value::Unknown; let y = Value::Null; assert_eq!(x.or(y), Value::Unknown); let x: Value = Value::Unknown; let y = Value::Unknown; assert_eq!(x.or(y), Value::Unknown); ``` -------------------------------- ### AttributePath Methods Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.AttributePath.html Methods for creating and modifying AttributePath instances. ```APIDOC ## AttributePath::new(name: T) Creates a new attribute path with the root attribute. ## AttributePath::root() Creates a new attribute path without any path component. ## AttributePath::function_argument(index: i64) Creates a new attribute path for a function argument. ## AttributePath::attribute(name: T) Appends an attribute access (.name) to the path. ## AttributePath::key(key: T) Appends a string subscript access (["key"]) to the path. ## AttributePath::index(idx: T) Appends an integer subscript access ([idx]) to the path. ``` -------------------------------- ### VZip trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Implementation of the vzip method for multi-lane types. ```rust fn vzip(self) -> V ``` -------------------------------- ### fn validate Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Validates the configuration of a resource. It records warnings and errors into the provided diagnostics object. ```APIDOC ## fn validate(&self, diags: &mut Diagnostics, config: RawValue) ### Description Validates the configuration of the resource. If the return is None, an ad-hoc error is added to diagnostics. ### Parameters - **diags** (Diagnostics) - Required - Diagnostics to record warnings and errors that occurred during validation. - **config** (RawValue) - Required - State as declared in the Terraform file. ``` -------------------------------- ### Use take to extract a value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Extracts the current value and replaces it with Value::Null. ```rust let mut x = Value::Value(2); let y = x.take(); assert_eq!(x, Value::Null); assert_eq!(y, Value::Value(2)); let mut x: Value = Value::Null; let y = x.take(); assert_eq!(x, Value::Null); assert_eq!(y, Value::Null); let mut x: Value = Value::Unknown; let y = x.take(); assert_eq!(x, Value::Null); assert_eq!(y, Value::Unknown); ``` -------------------------------- ### Upgrade resource state Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html Upgrades a resource from a prior version and state. Returns None if the upgrade fails, leaving the state unchanged. ```rust fn upgrade<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, version: i64, prior_state: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, ``` -------------------------------- ### as_mut_option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Transforms the &mut Value into an Option<&mut T>, mapping Value::Value(v) to Some(v), and both Value::Null and Value::Unknown to None. ```APIDOC ## pub fn as_mut_option(&mut self) -> Option<&mut T> ### Description Transforms the `&mut Value` into a `Option<&mut T>`, mapping `Value::Value(v)` to `Some(v)`, `Value::Null` to `None`, and `Value::Unknown` to `None`. ``` -------------------------------- ### Equivalent trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Methods for comparing a value to a key to determine equality. ```rust fn equivalent(&self, key: &K) -> bool ``` -------------------------------- ### Description Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Description.html The core structure definition for Description, containing the kind of string and the content itself. ```rust pub struct Description { pub kind: StringKind, pub content: String, } ``` -------------------------------- ### Upgrade resource state Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.Resource.html Upgrades a resource from a prior version. Requires explicit deserialization of the prior state. ```rust fn upgrade<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, version: i64, prior_state: RawValue, ) -> Pin>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, ``` -------------------------------- ### Map or Provide Default Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueEmpty.html Returns a default value if the variant is Null or Unknown, otherwise applies a function to the contained value. Use map_or_else for lazy evaluation of the default. ```rust let x = Value::Value("foo"); assert_eq!(x.map_or(42, |v| v.len()), 3); let x: Value<&str> = Value::Null; assert_eq!(x.map_or(42, |v| v.len()), 42); let x: Value<&str> = Value::Unknown; assert_eq!(x.map_or(42, |v| v.len()), 42); ``` -------------------------------- ### Expect a Value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns the contained value or panics with a custom message if the value is Null or Unknown. ```rust let x = Value::Value("value"); assert_eq!(x.expect("message"), "value"); ``` ```rust let x: Value<&str> = Value::Null; x.expect("message"); // panics with `message` ``` ```rust let x: Value<&str> = Value::Unknown; x.expect("message"); // panics with `message` ``` -------------------------------- ### Into trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Performs conversion into another type using the From implementation. ```rust fn into(self) -> U ``` -------------------------------- ### StringKind Enum Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/enum.StringKind.html Defines the available formatting options for string descriptions. ```rust pub enum StringKind { Plain = 0, Markdown = 1, } ``` -------------------------------- ### Convert Value to Option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Transforms a Value into an Option, mapping Value::Value to Some and others to None. ```rust let x = Value::Value("foo"); assert_eq!(x.as_option(), Some("foo")); let x: Value<&str> = Value::Null; assert_eq!(x.as_option(), None); let x: Value<&str> = Value::Unknown; assert_eq!(x.as_option(), None); ``` -------------------------------- ### Use or_else to provide a fallback value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns the existing value if present or unknown, otherwise executes the provided closure to retrieve a fallback. ```rust fn vikings() -> Value<&'static str> { Value::Value("vikings") } fn nobody() -> Value<&'static str> { Value::Null } fn unknown() -> Value<&'static str> { Value::Unknown } assert_eq!(Value::Value("barbarians").or_else(vikings), Value::Value("barbarians")); assert_eq!(Value::Value("barbarians").or_else(nobody), Value::Value("barbarians")); assert_eq!(Value::Value("barbarians").or_else(unknown), Value::Value("barbarians")); assert_eq!(Value::Null.or_else(vikings), Value::Value("vikings")); assert_eq!(Value::Null.or_else(nobody), Value::Null); assert_eq!(Value::Null.or_else(unknown), Value::Unknown); assert_eq!(Value::Unknown.or_else(vikings), Value::Unknown); assert_eq!(Value::Unknown.or_else(nobody), Value::Unknown); assert_eq!(Value::Unknown.or_else(unknown), Value::Unknown); ``` -------------------------------- ### or_else(self, f: F) -> Self Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueMap.html Returns the value if it contains a value or is unknown, otherwise calls the provided function and returns the result. ```APIDOC ## pub fn or_else(self, f: F) -> Self ### Description Returns the value if it contains a value or is unknown, otherwise calls `f` and returns the result. ### Parameters - **f** (FnOnce() -> Self) - Required - A function to call if the current value is Null. ``` -------------------------------- ### Parameter Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html The structure definition for a function parameter schema. ```rust pub struct Parameter { pub name: String, pub param_type: Type, pub allow_null: bool, pub allow_unknown: bool, pub description: Description, } ``` -------------------------------- ### Convert to Reference with as_ref Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Converts a Value to Value<&T> to allow mapping without consuming the original value. ```rust let text: Value = Value::Value("Hello, world!".to_string()); // First, cast `Value` to `Value<&String>` with `as_ref`, // then consume *that* with `map`, leaving `text` on the stack. let text_length: Value = text.as_ref().map(|s| s.len()); println!("still can print text: {text:?}"); ``` -------------------------------- ### Diagnostic Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html The core structure definition for Diagnostic. ```rust pub struct Diagnostic { pub summary: Cow<'static, str>, pub detail: Cow<'static, str>, pub attribute: AttributePath, } ``` -------------------------------- ### and(self, rhs: Value) -> Value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns Value::Null if the current value is Null, Value::Unknown if it is Unknown, otherwise returns the provided rhs value. ```APIDOC ## and(self, rhs: Value) -> Value ### Description Returns `Value::Null` if it is `Value::Null`, returns `Value::Unknown` if it is `Value::Unknown`, otherwise returns `rhs`. Arguments passed to `and` are eagerly evaluated. ### Parameters - **rhs** (Value) - Required - The value to return if the current value is not Null or Unknown. ``` -------------------------------- ### Unwrap with Default Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns the contained value or a provided default value. ```rust assert_eq!(Value::Value("car").unwrap_or("bike"), "car"); assert_eq!(Value::Null.unwrap_or("bike"), "bike"); assert_eq!(Value::Unknown.unwrap_or("bike"), "bike"); ``` -------------------------------- ### and_then(self, f: F) -> Value Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Chains fallible operations by applying a function to the wrapped value if it exists. ```APIDOC ## and_then(self, f: F) -> Value ### Description Returns `Value::Null` if it is `Value::Null`, returns `Value::Unknown` if it is `Value::Unknown`, otherwise calls `f` with the wrapped value and returns the result. This is lazily evaluated. ### Parameters - **f** (FnOnce(T) -> Value) - Required - The function to apply to the wrapped value. ``` -------------------------------- ### Define map macro structure Source: https://docs.rs/tf-provider/0.2.2/tf_provider/macro.map.html The macro definition supports trailing commas and multiple key-value pairs. ```rust macro_rules! map { {$($key:expr => $value:expr),*} => { ... }; {$($key:expr => $value:expr),+ ,} => { ... }; } ``` -------------------------------- ### FromRef trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Converts to the type from a reference to the input type. ```rust fn from_ref(input: &T) -> T ``` -------------------------------- ### Type Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html The definition of the ValueBool type alias. ```rust pub type ValueBool = Value; ``` -------------------------------- ### Instrument trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Methods for instrumenting types with spans for tracing. ```rust fn instrument(self, span: Span) -> Instrumented fn in_current_span(self) -> Instrumented ``` -------------------------------- ### pub fn filter

(self, predicate: P) -> Self Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueSet.html Returns Value::Null if it is Value::Null, returns Value::Unknown if it is Value::Unknown, otherwise calls predicate with the wrapped value. ```APIDOC ## pub fn filter

(self, predicate: P) -> Self ### Description Returns `Value::Null` if it is `Value::Null`, returns `Value::Unknown` if it is `Value::Unknown`, otherwise calls `predicate` with the wrapped value. Returns `Value::Value(t)` if `predicate` returns `true`, and `Value::Null` if `predicate` returns `false`. ``` -------------------------------- ### contains(&self, x: &U) -> bool Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Checks if the current value matches the provided value. ```APIDOC ## pub fn contains(&self, x: &U) -> bool ### Description Check if the value contains `x`. ### Parameters - **x** (&U) - Required - The value to check for equality. ``` -------------------------------- ### serialize(value: &Value, serializer: S) Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/serde_as_vec/fn.serialize.html Serializes a nullable Value into a Vec of Values with 0 or 1 element. ```APIDOC ## Function: serialize ### Description Serializes a nullable `Value` into a `Vec` of `Values` with 0 or 1 element. ### Signature `pub fn serialize(value: &Value, serializer: S) -> Result` ### Constraints - `S: Serializer` - `T: Serialize` ``` -------------------------------- ### or(self, rhs: Self) -> Self Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns the current value if it contains a value or is unknown, otherwise returns the provided rhs. ```APIDOC ## or(self, rhs: Self) -> Self ### Description Returns the value if it contains a value or is unknown, otherwise returns `rhs`. Arguments passed to `or` are eagerly evaluated. ### Parameters - **rhs** (Self) - Required - The fallback value to return if the current value is Null. ``` -------------------------------- ### Schema Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Schema.html The primary structure defining the schema version and its root block. ```rust pub struct Schema { pub version: i64, pub block: Block, } ``` -------------------------------- ### as_deref_mut_option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Converts from Value to Option<&mut T::Target> by coercing the contents via DerefMut. ```APIDOC ## pub fn as_deref_mut_option(&mut self) -> Option<&mut T::Target> ### Description Converts from `Value` (or `&mut Value`) to `Option<&mut T::Target>`, mapping `Value::Value(v)` to `Some(v)`, `Value::Null` to `None`, and `Value::Unknown` to `None`. ``` -------------------------------- ### Convert Function to DynamicFunction Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicFunction.html Implementation allowing conversion from a standard Function to a boxed DynamicFunction. ```rust impl From for Box ``` ```rust fn from(value: T) -> Self ``` -------------------------------- ### Resource Associated Types Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.Resource.html Associated types for defining resource state, private state, and provider metadata, all requiring serialization and deserialization capabilities. ```rust type State<'a>: Serialize + Deserialize<'a> + Send ``` ```rust type PrivateState<'a>: Serialize + Deserialize<'a> + Send ``` ```rust type ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send ``` -------------------------------- ### DynamicResource Trait Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicResource.html The trait definition includes required lifecycle methods like read, plan_create, and create, alongside optional methods for validation and imports. ```Rust pub trait DynamicResource: Send + Sync { // Required methods fn schema(&self, diags: &mut Diagnostics) -> Option; fn read<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, state: RawValue, private_state: Vec, provider_meta_state: RawValue, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn plan_create<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, proposed_state: RawValue, config_state: RawValue, provider_meta_state: RawValue, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn plan_update<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, prior_state: RawValue, proposed_state: RawValue, config_state: RawValue, prior_private_state: Vec, provider_meta_state: RawValue, ) -> Pin, Vec)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn plan_destroy<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, prior_state: RawValue, prior_private_state: Vec, provider_meta_state: RawValue, ) -> Pin>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, planned_state: RawValue, config_state: RawValue, planned_private_state: Vec, provider_meta_state: RawValue, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, prior_state: RawValue, planned_state: RawValue, config_state: RawValue, planned_private_state: Vec, provider_meta_state: RawValue, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn destroy<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, prior_state: RawValue, planned_private_state: Vec, provider_meta_state: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn validate<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn import<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, id: String, ) -> Pin)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn upgrade<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, version: i64, prior_state: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } } ``` -------------------------------- ### Convert Value to Reference Option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Transforms a reference to a Value into an Option containing a reference, useful for non-consuming operations. ```rust let text: Value = Value::Value("Hello, world!".to_string()); // First, cast `Value` to `Option<&String>` with `as_ref_option` let text_ref: Option<&String> = text.as_ref_option(); // then consume *that* with `map`, leaving `text` on the stack. let text_length: Option = text_ref.map(|s| s.len()); println!("still can print text: {text:?}"); ``` -------------------------------- ### WithSubscriber trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Methods for attaching subscribers to types for dispatching. ```rust fn with_subscriber(self, subscriber: S) -> WithDispatch fn with_current_subscriber(self) -> WithDispatch ``` -------------------------------- ### Attribute Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Attribute.html The structure definition for an attribute within the schema, containing type, description, constraint, and metadata flags. ```rust pub struct Attribute { pub attr_type: AttributeType, pub description: Description, pub constraint: AttributeConstraint, pub sensitive: bool, pub deprecated: bool, } ``` -------------------------------- ### DynamicProvider Trait Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DynamicProvider.html The core trait definition for implementing a dynamic provider, including required schema methods and optional lifecycle hooks. ```rust pub trait DynamicProvider: Send + Sync + 'static { // Required method fn schema(&self, diags: &mut Diagnostics) -> Option; // Provided methods fn validate<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn configure<'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, terraform_version: String, config: RawValue, ) -> Pin> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn meta_schema(&self, diags: &mut Diagnostics) -> Option { ... } fn get_resources( &self, diags: &mut Diagnostics, ) -> Option>> { ... } fn get_data_sources( &self, diags: &mut Diagnostics, ) -> Option>> { ... } fn get_functions( &self, diags: &mut Diagnostics, ) -> Option>> { ... } } ``` -------------------------------- ### Define the Function Trait Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.Function.html The core trait definition requiring Send and Sync, with associated types for input and output and methods for schema definition and execution. ```rust pub trait Function: Send + Sync { type Input<'a>: Deserialize<'a> + Send; type Output<'a>: Serialize + Send; // Required methods fn schema(&self, diags: &mut Diagnostics) -> Option; fn call<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, params: Self::Input<'a>, ) -> Pin>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; } ``` -------------------------------- ### serialize Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/serde_as_vec/index.html Serializes a nullable Value into a Vec of Values with 0 or 1 element. ```APIDOC ## serialize ### Description Serializes a nullable Value into a Vec of Values with 0 or 1 element. ### Signature `fn serialize(value: &Option, serializer: S) -> Result where S: Serializer` ``` -------------------------------- ### Define the DataSource trait Source: https://docs.rs/tf-provider/0.2.2/tf_provider/trait.DataSource.html The core trait definition including required associated types for state management and methods for schema definition, reading, and validation. ```rust 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; fn read<'a, 'life0, 'life1, 'async_trait>( &'life0 self, diags: &'life1 mut Diagnostics, config: Self::State<'a>, provider_meta_state: Self::ProviderMetaState<'a>, ) -> Pin>> + 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> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } } ``` -------------------------------- ### IntoRequest trait implementation Source: https://docs.rs/tf-provider/0.2.2/tf_provider/schema/struct.Parameter.html Wraps the input message in a tonic Request. ```rust fn into_request(self) -> Request ``` -------------------------------- ### as_deref_option Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html Converts from Value to Option<&T::Target> by coercing the contents via Deref. ```APIDOC ## pub fn as_deref_option(&self) -> Option<&T::Target> ### Description Converts from `Value` (or `&Value`) to `Option<&T::Target>`, mapping `Value::Value(v)` to `Some(v)`, `Value::Null` to `None`, and `Value::Unknown` to `None`. ``` -------------------------------- ### Diagnostic::function Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.Diagnostic.html Creates a diagnostic specifically for a function argument. ```APIDOC ## Diagnostic::function(index, message) ### Description Creates a diagnostic for a function argument. ### Parameters - **index** (i64) - Required - Index of the argument triggering the diagnostics - **message** (S: Into>) - Required - Short message of the diagnostics ``` -------------------------------- ### Convert Value to Result Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Transforms a Value into a Result, mapping Null or Unknown states to an error. ```rust let x = Value::Value("foo"); assert_eq!(x.ok_or(0), Ok("foo")); let x: Value<&str> = Value::Null; assert_eq!(x.ok_or(0), Err(0)); let x: Value<&str> = Value::Unknown; assert_eq!(x.ok_or(0), Err(0)); ``` ```rust let x = Value::Value("foo"); assert_eq!(x.ok_or_else(|| 0), Ok("foo")); let x: Value<&str> = Value::Null; assert_eq!(x.ok_or_else(|| 0), Err(0)); let x: Value<&str> = Value::Unknown; assert_eq!(x.ok_or_else(|| 0), Err(0)); ``` -------------------------------- ### Define AttributePath struct Source: https://docs.rs/tf-provider/0.2.2/tf_provider/struct.AttributePath.html The internal structure of AttributePath containing a vector of steps. ```rust pub struct AttributePath { pub steps: Vec, } ``` -------------------------------- ### Filtering Value instances Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Applies a predicate to a Value, returning the original value if the predicate is true, or Null if false. ```rust fn is_even(n: &i32) -> bool { n % 2 == 0 } assert_eq!(Value::Value(4).filter(is_even), Value::Value(4)); assert_eq!(Value::Value(3).filter(is_even), Value::Null); assert_eq!(Value::Null.filter(is_even), Value::Null); assert_eq!(Value::Unknown.filter(is_even), Value::Unknown); ``` -------------------------------- ### ValueList Type Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueList.html The type alias and enum structure for ValueList. ```rust pub type ValueList = Value>; ``` ```rust pub enum ValueList { Value(Vec), Null, Unknown, } ``` -------------------------------- ### Unwrap with Closure Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/type.ValueBool.html Returns the contained value or computes a default value using a closure. ```rust let k = 10; assert_eq!(Value::Value(4).unwrap_or_else(|| 2 * k), 4); assert_eq!(Value::Null.unwrap_or_else(|| 2 * k), 20); assert_eq!(Value::Unknown.unwrap_or_else(|| 2 * k), 20); ``` -------------------------------- ### IntoIter Struct Definition Source: https://docs.rs/tf-provider/0.2.2/tf_provider/value/struct.IntoIter.html The basic structure definition for IntoIter. ```rust pub struct IntoIter { /* private fields */ } ```