@@ -41,8 +41,10 @@ pub enum BorrowState {
4141
4242/// Raw account data.
4343///
44- /// This data is wrapped in an `AccountInfo` struct, which provides safe access
45- /// to the data.
44+ /// This struct is wrapped by [`AccountInfo`], which provides safe access
45+ /// to account information. At runtime, the account's data is serialized
46+ /// directly after the [`Account`] struct in memory, with its size specified
47+ /// by [`Account::data_len`].
4648#[ repr( C ) ]
4749#[ derive( Clone , Copy , Default ) ]
4850pub ( crate ) struct Account {
@@ -112,9 +114,20 @@ pub(crate) struct Account {
112114
113115/// Wrapper struct for an `Account`.
114116///
115- /// This struct provides safe access to the data in an `Account`. It is also
116- /// used to track borrows of the account data and lamports, given that an
117- /// account can be "shared" across multiple `AccountInfo` instances.
117+ /// This struct provides safe access to the data in an `Account`. It is
118+ /// also used to track borrows of the account data and lamports, given
119+ /// that an account can be "shared" across multiple `AccountInfo`
120+ /// instances.
121+ ///
122+ /// # Invariants
123+ ///
124+ /// - The `raw` pointer must be valid and point to memory containing an
125+ /// [`Account`] struct, immediately followed by the account's data region.
126+ /// - The length of the account data must exactly match the value stored in
127+ /// [`Account::data_len`].
128+ ///
129+ /// These conditions must always hold for any `AccountInfo` created from
130+ /// a raw pointer.
118131#[ repr( C ) ]
119132#[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
120133pub struct AccountInfo {
0 commit comments