### Anchor IDL Crate API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/index Detailed API documentation for the `anchor_idl` Rust crate, outlining its core functionality and listing all exposed structs, along with categories for enums, constants, functions, and type aliases. ```APIDOC Crate anchor_idl Description: Generates Rust code from an Anchor IDL. Crate Items: Structs: anchor_idl::FieldListProperties anchor_idl::Generator anchor_idl::GeneratorOptions anchor_idl::Idl anchor_idl::IdlAccount anchor_idl::IdlConst anchor_idl::IdlDependency anchor_idl::IdlDeployments anchor_idl::IdlEnumVariant anchor_idl::IdlErrorCode anchor_idl::IdlEvent anchor_idl::IdlField anchor_idl::IdlInstruction anchor_idl::IdlInstructionAccount anchor_idl::IdlInstructionAccounts anchor_idl::IdlMetadata anchor_idl::IdlPda anchor_idl::IdlReprModifier anchor_idl::IdlSeedAccount anchor_idl::IdlSeedArg anchor_idl::IdlSeedConst anchor_idl::IdlTypeDef anchor_idl::StructOpts Enums: (Not detailed in this section) Constants: (Not detailed in this section) Functions: (Not detailed in this section) Type Aliases: (Not detailed in this section) ``` -------------------------------- ### Rust Any Trait: Get TypeId Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlErrorCode Gets the `TypeId` of `self`. This method is part of the `Any` trait, allowing runtime type identification. ```APIDOC fn type_id(&self) -> TypeId Gets the TypeId of self. ``` -------------------------------- ### Anchor IDL Constants Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/index Defines constants available within the `anchor_idl` crate. This section includes important version information for the `anchor-idl` tool and the semantic version of the IDL specification it adheres to. ```APIDOC Constants: GEN_VERSION: Version of anchor-idl. IDL_SPEC: IDL specification Semantic Version ``` -------------------------------- ### Any Trait Method: type_id Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlConst Gets the `TypeId` of `self`. This method is part of the `Any` trait, enabling dynamic type introspection. ```APIDOC fn type_id(&self) -> TypeId &self: A reference to the current instance. Returns: The `TypeId` of the instance. ``` -------------------------------- ### API Documentation for Rust's CloneToUninit Trait Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlSeedConst Documents the `CloneToUninit` trait, an experimental API for performing copy-assignment from `self` to an uninitialized destination. ```APIDOC impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8) Description: Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. } ``` -------------------------------- ### Rust Any Trait: type_id Method Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlDefinedFields Gets the `TypeId` of `self`. This method is part of the `core::any::Any` trait and allows for dynamic type introspection. ```APIDOC fn type_id(&self) -> TypeId ``` -------------------------------- ### Get TypeId of self (Any trait) Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlSeed This method, part of the `Any` trait, returns the `TypeId` of the concrete type of `self`. This `TypeId` can be used for runtime type identification and downcasting. ```Rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Anchor IDL Constants Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl Details the public constants defined within the `anchor_idl` crate. These constants provide version information for the `anchor-idl` tool and the IDL specification. ```APIDOC Constants: GEN_VERSION: Version of anchor-idl. IDL_SPEC: IDL specification Semantic Version ``` -------------------------------- ### APIDOC: IdlEvent Struct Details and Trait Implementations Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlEvent Detailed API documentation for the `IdlEvent` struct, outlining its public fields and a comprehensive list of all implemented traits, including explicit, auto, and blanket implementations. ```APIDOC IdlEvent Struct: Source: https://docs.rs/anchor-lang-idl-spec/0.1.0/x86_64-unknown-linux-gnu/src/anchor_lang_idl_spec/lib.rs.html#142 Fields: - name: String (https://doc.rust-lang.org/nightly/alloc/string/struct.String.html) - discriminator: Vec (https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html, https://doc.rust-lang.org/nightly/std/primitive.u8.html) Trait Implementations: - Clone (Source: https://docs.rs/anchor-lang-idl-spec/0.1.0/x86_64-unknown-linux-gnu/src/anchor_lang_idl_spec/lib.rs.html#141) - Debug - Deserialize<'de> - PartialEq - Serialize - StructuralPartialEq Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe Blanket Implementations: - Any - Borrow - BorrowMut - CloneToUninit - DeserializeOwned - From - Into - ToOwned - TryFrom - TryInto ``` -------------------------------- ### Rust Any Trait: Get TypeId Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlInstructionAccountItem Documents the `type_id` method of the `Any` trait, which allows retrieving the `TypeId` of a value. This is useful for runtime type identification and downcasting. ```APIDOC Trait: Any impl Any for T where T: 'static + ?Sized Method: type_id Signature: (&self) -> TypeId Description: Gets the TypeId of self. ``` -------------------------------- ### Rust Blanket Implementation of Any Trait Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlMetadata Details the blanket implementation of the `Any` trait for any type `T` that is `'static` and potentially `Sized`, providing a method to get the `TypeId` of an instance. ```APIDOC impl Any for T where T: 'static + ?Sized Methods: type_id(&self) -> TypeId Description: Gets the TypeId of self. ``` -------------------------------- ### API Documentation for IdlInstructionAccount Struct Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstructionAccount Comprehensive API documentation for the `IdlInstructionAccount` struct, detailing its fields, trait implementations (e.g., Clone, Debug, Deserialize, Serialize), auto trait implementations, and blanket implementations. This provides a complete overview of its structure and behavior within the Anchor framework, crucial for understanding how instruction accounts are defined and handled. ```APIDOC Struct: IdlInstructionAccount Fields: - address: Option - docs: Vec - name: String - optional: bool - pda: Option - relations: Vec - signer: bool - writable: bool Trait Implementations: - Clone - Debug - Deserialize<'de> - PartialEq - Serialize - StructuralPartialEq Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe Blanket Implementations: - Any - Borrow - BorrowMut - CloneToUninit - DeserializeOwned - From - Into - ToOwned - TryFrom - TryInto ``` -------------------------------- ### Rust Any Trait: Get TypeId Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.FieldListProperties Retrieves the unique `TypeId` for the given instance of `self`. This method is part of the `Any` trait, enabling runtime type identification. ```APIDOC fn type_id(&self) -> TypeId ``` -------------------------------- ### Rust CloneToUninit Trait: clone_to_uninit method Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstructionAccounts Documents the `clone_to_uninit` method of the `CloneToUninit` trait, which performs a copy-assignment from `self` to a raw pointer `dest`. This is an experimental nightly-only API. ```APIDOC unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from self to dest. ``` -------------------------------- ### IdlDeployments Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlDeployments Detailed API documentation for the `IdlDeployments` struct, outlining its public fields and all traits it implements, including standard Rust traits like `Clone`, `Debug`, `PartialEq`, and serialization traits `Deserialize` and `Serialize`. ```APIDOC Struct: IdlDeployments Description: Represents a collection of optional IDL deployment URLs for different network environments. Source: https://docs.rs/anchor-lang-idl-spec/0.1.0/x86_64-unknown-linux-gnu/src/anchor_lang_idl_spec/lib.rs.html#52 Fields: devnet: Option - Optional URL for the devnet deployment. localnet: Option - Optional URL for the localnet deployment. mainnet: Option - Optional URL for the mainnet deployment. testnet: Option - Optional URL for the testnet deployment. Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### Rust Blanket Trait Implementation: Borrow for T Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlTypeDefTy A blanket implementation of the `Borrow` trait for any type `T`. This allows a type to be borrowed as itself, providing a consistent way to get a reference to an owned value. ```Rust impl Borrow for T ``` -------------------------------- ### Rust Any Trait Method: fn type_id Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlSeedAccount Retrieves the `TypeId` of the current instance. This method is part of the `Any` trait, enabling runtime reflection to get a unique identifier for the type of `self`. ```APIDOC fn type_id(&self) -> TypeId ``` -------------------------------- ### IdlEnumVariant Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlEnumVariant Comprehensive API documentation for the `IdlEnumVariant` struct, detailing its methods and behavior as defined by its implementations of the `Clone`, `Debug`, `Deserialize`, and `PartialEq` traits. This section provides signatures, parameters, return types, and descriptions for each method. ```APIDOC IdlEnumVariant struct API: // Trait Implementations impl Clone: fn clone(&self) -> IdlEnumVariant Returns: IdlEnumVariant - A copy of the value. Description: Returns a copy of the value. fn clone_from(&mut self, source: &Self) source: &Self - The source value to copy from. Description: Performs copy-assignment from `source`. impl Debug: fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> f: &mut Formatter<'_> - The formatter to use. Returns: Result<(), Error> - A Result indicating success or failure of formatting. Description: Formats the value using the given formatter. impl<'de> Deserialize<'de>: fn deserialize<__D>(__deserializer: __D) -> Result>::Error> __deserializer: __D - The Serde deserializer. Returns: Result>::Error> - A Result containing the deserialized IdlEnumVariant or an error. Description: Deserializes this value from the given Serde deserializer. impl PartialEq: fn eq(&self, other: &IdlEnumVariant) -> bool other: &IdlEnumVariant - The other IdlEnumVariant to compare with. Returns: bool - True if the values are equal, false otherwise. Description: Tests for `self` and `other` values to be equal, and is used by `==`. ``` -------------------------------- ### IdlConst Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlConst Detailed API documentation for the `IdlConst` struct, outlining its public fields, their types, and all traits that `IdlConst` implements, including standard, auto, and blanket implementations. ```APIDOC IdlConst: Fields: name: String docs: Vec ty: IdlType value: String Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### Rust Borrow Trait: Immutably Borrow Value Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.FieldListProperties Immutably borrows from an owned value, returning a reference `&T`. This method is part of the `Borrow` trait, providing a consistent way to get a reference. ```APIDOC fn borrow(&self) -> &T ``` -------------------------------- ### Rust CloneToUninit Trait and clone_to_uninit Method (Nightly API) Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlAccount Documents the experimental `CloneToUninit` trait and its `clone_to_uninit` method, which performs copy-assignment from `self` to a raw pointer destination. This is a nightly-only API for advanced memory manipulation. ```APIDOC Trait: CloneToUninit for T where T: Clone Method: clone_to_uninit Signature: unsafe fn clone_to_uninit(&self, dest: *mut u8) Description: Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ``` -------------------------------- ### APIDOC: GeneratorOptions Struct Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.GeneratorOptions Detailed API documentation for the `GeneratorOptions` struct, outlining its public fields, methods, and various trait implementations. This section provides a comprehensive overview of how to interact with and configure the IDL generator within the `anchor-idl` crate. ```APIDOC Struct: GeneratorOptions Fields: idl_path: String skip: Option zero_copy: Option packed: Option Methods: to_generator Trait Implementations: Default FromMeta Auto Trait Implementations: !Send !Sync Freeze RefUnwindSafe Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut From Into TryFrom TryInto ``` -------------------------------- ### Anchor IDL Crate API Reference: Structs Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl This section provides a reference to the public structs available within the `anchor_idl` crate. These structs represent various components and data structures used in the Anchor IDL generation process, such as definitions for accounts, instructions, fields, and overall IDL structure. ```APIDOC Crate: anchor_idl Description: Generates Rust code from an Anchor IDL. Structs: - FieldListProperties - Generator - GeneratorOptions - Idl - IdlAccount - IdlConst - IdlDependency - IdlDeployments - IdlEnumVariant - IdlErrorCode - IdlEvent - IdlField - IdlInstruction - IdlInstructionAccount - IdlInstructionAccounts - IdlMetadata - IdlPda - IdlReprModifier - IdlSeedAccount - IdlSeedArg - IdlSeedConst - IdlTypeDef - StructOpts ``` -------------------------------- ### APIDOC: anchor_idl::StructOpts Struct Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.StructOpts Comprehensive API documentation for the `StructOpts` struct within the `anchor_idl` crate. This section details its public fields, explicitly implemented traits, automatically derived traits, and blanket implementations, providing a complete overview of its capabilities and behavior. ```APIDOC Struct StructOpts: Source: ../src/anchor_idl/program.rs.html#72-76 Fields: skip: bool packed: bool zero_copy: bool Trait Implementations: Clone: fn clone(&self) -> StructOpts Description: Returns a copy of the value. Copy Debug Default Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit From Into ToOwned TryFrom TryInto ``` -------------------------------- ### IdlErrorCode Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlErrorCode Comprehensive API documentation for the `IdlErrorCode` struct, detailing its public fields and all implemented traits, including standard Rust traits and those for serialization/deserialization. ```APIDOC IdlErrorCode: Fields: code: u32 name: String msg: Option Trait Implementations: Clone Debug Deserialize<'de> Eq PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### IdlSeedAccount Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlSeedAccount Detailed API documentation for the `IdlSeedAccount` struct, covering its public fields and all traits it implements, including standard, auto, and blanket implementations. ```APIDOC Struct: IdlSeedAccount Source: https://docs.rs/anchor-lang-idl-spec/0.1.0/x86_64-unknown-linux-gnu/src/anchor_lang_idl_spec/lib.rs.html#129 Fields: path: String (https://doc.rust-lang.org/nightly/alloc/string/struct.String.html) account: Option (https://doc.rust-lang.org/nightly/core/option/enum.Option.html) Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### Idl Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.Idl Comprehensive API documentation for the `Idl` struct, detailing its public fields, standard trait implementations (like `Clone`, `Debug`, `Serialize`), auto trait implementations, and blanket implementations. This outlines the programmatic interface of the IDL structure. ```APIDOC Idl Struct: Fields: accounts: Vec address: String constants: Vec docs: Vec errors: Vec events: Vec instructions: Vec metadata: IdlMetadata types: Vec Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### Anchor IDL Functions Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/index Provides a comprehensive list of functions implemented in the `anchor_idl` crate. These functions are primarily responsible for generating various Anchor IDL-related Rust structures, including accounts, enums, events, and instruction handlers. It also includes utility functions for type conversion and property retrieval. ```APIDOC Functions: generate_account: Generates an account state struct. generate_account_fields: Generates a list of IdlAccountItems as a TokenStream. generate_accounts: Generates account state structs. generate_enum: Generates an enum. generate_enum_fields: Generates enum fields from a list of IdlFields. generate_enum_tuple_types: Generates enum tuple types from a list of IdlTypes. generate_event: Generates a struct. generate_events: Generates event structs. generate_ix_handler: Generates a single instruction handler. generate_ix_handlers: Generates all instruction handlers. generate_ix_structs: Generates instruction context structs. generate_struct: Generates a struct. generate_typedefs: Generates structs and enums. get_defined_fields_list_properties get_field_list_properties get_type_list_properties get_type_properties get_variant_list_properties ty_to_rust_type: Converts an IdlType to a String of the Rust representation. ``` -------------------------------- ### Rust CloneToUninit Trait Implementation for T Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstructionAccounts Documents the blanket implementation of the `CloneToUninit` trait for any type `T` that implements `Clone`, enabling cloning into uninitialized memory. This is an experimental nightly-only API. ```APIDOC impl CloneToUninit for T where T: Clone, ``` -------------------------------- ### FieldListProperties Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.FieldListProperties Comprehensive API documentation for the `FieldListProperties` struct in the `anchor_idl` crate. This section details its fields, explicitly implemented traits, automatically derived traits, and blanket implementations, providing a full overview of its capabilities and behavior. ```APIDOC Struct: FieldListProperties Description: Properties related to field lists within the Anchor IDL. Source: ../src/anchor_idl/typedef.rs.html#16-19 Fields: - can_copy: bool Description: Indicates if the field list can be copied. - can_derive_default: bool Description: Indicates if the field list can derive default implementations. Trait Implementations: - Clone - Copy - Debug - Default Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe Blanket Implementations: - Any - Borrow - BorrowMut - CloneToUninit - From - Into - ToOwned - TryFrom - TryInto ``` -------------------------------- ### APIDOC: IdlInstructionAccounts Struct Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstructionAccounts Comprehensive API documentation for the `IdlInstructionAccounts` struct, detailing its public fields, explicitly implemented traits, automatically derived traits, and blanket implementations. This struct is fundamental for defining instruction accounts within the Anchor IDL specification. ```APIDOC Struct: IdlInstructionAccounts Source: https://docs.rs/anchor-lang-idl-spec/0.1.0/x86_64-unknown-linux-gnu/src/anchor_lang_idl_spec/lib.rs.html#98 Fields: - name: String (https://doc.rust-lang.org/nightly/alloc/string/struct.String.html) - accounts: Vec (https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html) Trait Implementations: - Clone - Debug - Deserialize<'de> - PartialEq - Serialize - StructuralPartialEq Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe Blanket Implementations: - Any - Borrow - BorrowMut - CloneToUninit - DeserializeOwned - From - Into - ToOwned - TryFrom - TryInto ``` -------------------------------- ### Anchor IDL Functions Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl Outlines the public functions provided by the `anchor_idl` crate. These functions are primarily responsible for generating various Anchor IDL components, including accounts, enums, events, and instruction handlers, and for converting IDL types to Rust representations. ```APIDOC Functions: generate_account: Generates an account state struct. generate_account_fields: Generates a list of IdlAccountItems as a TokenStream. generate_accounts: Generates account state structs. generate_enum: Generates an enum. generate_enum_fields: Generates enum fields from a list of IdlFields. generate_enum_tuple_types: Generates enum tuple types from a list of IdlTypes. generate_event: Generates a struct. generate_events: Generates event structs. generate_ix_handler: Generates a single instruction handler. generate_ix_handlers: Generates all instruction handlers. generate_ix_structs: Generates instruction context structs. generate_struct: Generates a struct. generate_typedefs: Generates structs and enums. get_defined_fields_list_properties get_field_list_properties get_type_list_properties get_type_properties get_variant_list_properties ty_to_rust_type: Converts an IdlType to a String of the Rust representation. ``` -------------------------------- ### Rust CloneToUninit Trait: clone_to_uninit method Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlRepr Documents the `clone_to_uninit` method of the `CloneToUninit` trait. This is a nightly-only experimental API that performs copy-assignment from `self` to an uninitialized destination pointer. ```APIDOC Trait: CloneToUninit Impl: for T where T: Clone Method: clone_to_uninit Signature: unsafe fn (&self, dest: *mut u8) Description: Performs copy-assignment from `self` to `dest`. Note: This is a nightly-only experimental API (`clone_to_uninit`). ``` -------------------------------- ### Rust Core `TryFrom` and `TryInto` Trait API Documentation Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlPda Documents the `TryFrom` and `TryInto` traits in Rust, which provide mechanisms for fallible type conversions. It details their associated `Error` types and the `try_from` and `try_into` methods, respectively, for performing these conversions. ```APIDOC Trait: TryFrom Associated Type: Error Definition: type Error = Infallible Description: The type returned in the event of a conversion error. Method: try_from(value: U) Signature: fn try_from(value: U) -> Result>::Error> Description: Performs the conversion. Trait: TryInto for T where U: TryFrom Associated Type: Error Definition: type Error = >::Error Description: The type returned in the event of a conversion error. Method: try_into(self) Signature: fn try_into(self) -> Result>::Error> Description: Performs the conversion. ``` -------------------------------- ### IdlPda Struct API Documentation Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlPda Comprehensive API documentation for the `IdlPda` struct, detailing its public fields (`program`, `seeds`) and various trait implementations including `Clone`, `Debug`, `Deserialize`, `PartialEq`, `Serialize`, and others. This section outlines the capabilities and behavior of the `IdlPda` struct. ```APIDOC IdlPda Struct Fields: program: Option seeds: Vec Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### API Documentation for IdlEnumVariant Struct Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlEnumVariant Comprehensive API documentation for the `IdlEnumVariant` struct, detailing its fields with types, standard trait implementations, auto-derived trait implementations, and blanket implementations. ```APIDOC Class: IdlEnumVariant Fields: name: String fields: Option Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### IdlInstruction Structure Fields Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstruction Defines the fields of the `IdlInstruction` struct, including its name, documentation, discriminator, accounts, arguments, and return type. ```APIDOC IdlInstruction: name: String docs: Vec discriminator: Vec accounts: Vec args: Vec returns: Option ``` -------------------------------- ### Idl PartialEq ne Method Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.Idl API documentation for the `ne` method, which tests if two `Idl` values are not equal. The default implementation is typically sufficient. This method is part of the `PartialEq` trait implementation for the `Idl` struct. ```APIDOC fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Rust `generate_accounts` Function API Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/fn.generate_accounts API documentation for the `generate_accounts` function within the `anchor_idl` crate. This function takes IDL type definitions, account definitions, and struct options to produce a `TokenStream` for generating account state structs. ```APIDOC generate_accounts( typedefs: &[IdlTypeDef], account_defs: &[IdlAccount], struct_opts: &BTreeMap ) -> TokenStream ``` -------------------------------- ### IdlAccount Struct API Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlAccount Comprehensive API documentation for the `IdlAccount` struct, detailing its fields and all implemented traits, including standard, auto, and blanket implementations. This provides insight into the struct's capabilities and how it interacts with the Rust type system. ```APIDOC Struct: IdlAccount Fields: discriminator: Vec name: String Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### Rust Blanket Implementation of CloneToUninit Trait (Nightly API) Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlInstructionAccount Details the blanket implementation of the experimental `CloneToUninit` trait for any type `T` that implements `Clone`. Includes the `clone_to_uninit` method for performing copy-assignment to uninitialized memory. ```APIDOC impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### APIDOC for IdlMetadata Struct Overview Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlMetadata This section provides a structured API overview of the `IdlMetadata` struct, detailing its fields and all trait implementations. It serves as a reference for understanding the struct's data model and its behavior within the Anchor framework, including serialization, deserialization, and common Rust traits. ```APIDOC Struct: IdlMetadata Fields: contact: Option dependencies: Vec deployments: Option description: Option name: String repository: Option spec: String version: String Trait Implementations: Clone Debug Deserialize<'de> PartialEq Serialize StructuralPartialEq Auto Trait Implementations: Freeze RefUnwindSafe Send Sync Unpin UnwindSafe Blanket Implementations: Any Borrow BorrowMut CloneToUninit DeserializeOwned From Into ToOwned TryFrom TryInto ``` -------------------------------- ### API Documentation for Rust's TryFrom Trait Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlSeedConst Documents the `TryFrom` trait, which allows for fallible conversions from one type to another. No methods or associated types are detailed in the provided text for this implementation. ```APIDOC impl TryFrom for T { // No methods or associated types shown in the provided text. } ``` -------------------------------- ### APIDOC: anchor_idl::Generator Struct Reference Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.Generator Detailed API documentation for the `Generator` struct within the `anchor_idl` crate, outlining its public fields, methods, and automatically implemented traits. This reference is crucial for understanding how to interact with and extend the IDL generation capabilities. ```APIDOC anchor_idl::Generator: Fields: idl: Idl (struct anchor_idl::Idl) struct_opts: BTreeMap (alloc::collections::btree::map::BTreeMap) Methods: generate_cpi_interface(&self) -> TokenStream (proc_macro2::TokenStream) Auto Trait Implementations: Freeze for Generator (core::marker::Freeze) RefUnwindSafe for Generator (core::marker::RefUnwindSafe) Send for Generator (core::marker::Send) Sync for Generator (core::marker::Sync) Unpin for Generator (core::marker::Unpin) UnwindSafe for Generator (core::marker::UnwindSafe) Blanket Implementations: Any for T Borrow for T BorrowMut for T From for T Into for T TryFrom for T TryInto for T ``` -------------------------------- ### Implement Serialize::serialize for IdlGenericArg Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlGenericArg Documents the `serialize` method, which is part of the `serde::Serialize` trait. This method defines how `IdlGenericArg` instances are converted into a serializable format using a Serde `Serializer`. ```Rust fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where __S: Serializer, ``` -------------------------------- ### Initialize Anchor IDL Generator from Options Source: https://docs.rs/anchor-idl/0.4.1/src/anchor_idl/program.rs This implementation block for `GeneratorOptions` provides the `to_generator` method, which is responsible for reading and parsing the Anchor IDL file specified by `idl_path`. It then processes the `skip`, `zero_copy`, and `packed` options, mapping them to a `BTreeMap` of `StructOpts` for each relevant type found in the IDL, ultimately initializing and returning a `Generator` instance. ```Rust impl GeneratorOptions { pub fn to_generator(&self) -> Generator { let cargo_manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let path = PathBuf::from(cargo_manifest_dir).join(&self.idl_path); let idl_contents = fs::read_to_string(&path).unwrap(); let idl: anchor_lang_idl_spec::Idl = serde_json::from_str(&idl_contents).unwrap(); let skip = path_list_to_string(self.skip.as_ref()); let zero_copy = path_list_to_string(self.zero_copy.as_ref()); let packed = path_list_to_string(self.packed.as_ref()); let all_type_names = idl .accounts .iter() .map(|a| a.name.clone()) .chain(idl.types.iter().map(|t| t.name.clone())) .collect::>(); let mut struct_opts: BTreeMap = BTreeMap::new(); all_type_names.iter().for_each(|name| { struct_opts.insert( name.to_string(), StructOpts { skip: skip.contains(name), zero_copy: zero_copy.contains(name), packed: packed.contains(name), }, ); }); Generator { idl, struct_opts } } } ``` -------------------------------- ### Rust CloneToUninit Trait: `clone_to_uninit` Method Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlDefinedFields Performs copy-assignment from `self` to `dest`. This is an `unsafe` nightly-only experimental API for the `CloneToUninit` trait, used for cloning data into uninitialized memory. ```APIDOC impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### API Documentation for Rust's From Trait Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlSeedConst Documents the `From` trait, which allows for infallible conversions from one type to another. ```APIDOC impl From for T { fn from(t: T) -> T Description: Returns the argument unchanged. } ``` -------------------------------- ### API Documentation for IdlInstructionAccountItem Enum Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlInstructionAccountItem Comprehensive API documentation for the `IdlInstructionAccountItem` enum, detailing its variants, directly implemented traits, auto-implemented traits, and blanket implementations. This provides a full overview of the enum's behavior and capabilities. ```APIDOC IdlInstructionAccountItem: Variants: - Composite(IdlInstructionAccounts): Represents a composite set of instruction accounts. - Single(IdlInstructionAccount): Represents a single instruction account. Trait Implementations: - Clone - Debug - Deserialize<'de> - PartialEq - Serialize - StructuralPartialEq Auto Trait Implementations: - Freeze - RefUnwindSafe - Send - Sync - Unpin - UnwindSafe Blanket Implementations: - Any - Borrow - BorrowMut - CloneToUninit - DeserializeOwned - From - Into - ToOwned - TryFrom - TryInto ``` -------------------------------- ### Rust CloneToUninit Trait Implementation for T Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlEvent Documents the experimental `CloneToUninit` trait implementation for types that are `Clone`. This nightly-only API performs a copy-assignment from `self` to an uninitialized memory destination. ```APIDOC impl CloneToUninit for T where T: Clone unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. (`clone_to_uninit`) ``` -------------------------------- ### Generate Anchor Instruction Context Structs (Rust) Source: https://docs.rs/anchor-idl/0.4.1/src/anchor_idl/instruction.rs This Rust function generates a collection of instruction context structs for an Anchor program. It iterates through a slice of `IdlInstruction`s, creating a new struct for each instruction's accounts. The generated structs are annotated with `#[derive(Accounts)]` and include fields for all associated accounts. It handles both empty and non-empty account lists, conditionally adding a lifetime parameter `'info` if accounts are present. This function relies on `anchor_lang_idl_spec`, `heck`, `proc_macro2`, and `quote` crates. ```Rust pub fn generate_ix_structs(ixs: &[IdlInstruction]) -> TokenStream { let defs = ixs.iter().map(|ix| { let accounts_name = format_ident!("{}", ix.name.to_pascal_case()); let (all_structs, all_fields) = crate::generate_account_fields(&ix.name.to_pascal_case(), &ix.accounts); let struct_def = if ix.accounts.is_empty() { quote! { pub struct #accounts_name { #all_fields } } } else { quote! { pub struct #accounts_name<'info> { #all_fields } } }; quote! { #all_structs #[derive(Accounts)] #struct_def } }); quote! { #(#defs)* } } ``` -------------------------------- ### Implement CloneToUninit Trait for Generic Type T Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.Idl Documents the blanket implementation of the `CloneToUninit` trait for any type `T` that implements `Clone`. This is a nightly-only experimental API for performing copy-assignment to uninitialized memory. ```APIDOC impl CloneToUninit for T where T: Clone, unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Implement Serde Serialize for IdlInstructionAccountItem Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/enum.IdlInstructionAccountItem Provides the necessary implementation for `IdlInstructionAccountItem` to be serialized using the Serde framework. This allows converting instances of the enum into various data formats. ```APIDOC impl Serialize for IdlInstructionAccountItem { fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where __S: Serializer, } ``` -------------------------------- ### Serialize `IdlDeployments` using Serde Source: https://docs.rs/anchor-idl/0.4.1/anchor_idl/struct.IdlDeployments Defines how to serialize an `IdlDeployments` instance into a Serde serializer. This method is part of the `Serialize` trait implementation for `IdlDeployments`, enabling conversion to various data formats. ```APIDOC fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where __S: Serializer, ```