hopper_core/accounts/traits.rs
1//! Account validation and explain traits.
2
3use hopper_runtime::error::ProgramError;
4
5/// Trait for accounts that can self-validate.
6///
7/// Automatically satisfied by construction for modifier-wrapped types.
8/// Useful for custom account implementations that need a post-construction
9/// validation pass.
10pub trait ValidateAccount {
11 /// Run all validation checks. Returns `Ok(())` if valid.
12 fn validate(&self) -> Result<(), ProgramError>;
13}
14
15/// Trait for accounts that can produce a structured explanation.
16#[cfg(feature = "explain")]
17pub trait ExplainAccount {
18 /// Generate a human-readable explanation of this account.
19 fn explain(&self) -> super::explain::AccountExplain;
20}