Add crate docs for solana-program (#23363)

* Add crate docs for solana-program

* Rework solana-program docs for pr feedback

* Clarify log module docs

* Remove address lookup table program from solana-program docs
This commit is contained in:
Brian Anderson
2022-03-18 10:27:51 -05:00
committed by GitHub
parent f54e746fc5
commit c9b8977226
3 changed files with 625 additions and 23 deletions

View File

@@ -101,6 +101,13 @@ pub trait Sysvar:
fn size_of() -> usize {
bincode::serialized_size(&Self::default()).unwrap() as usize
}
/// Deserializes a sysvar from its `AccountInfo`.
///
/// # Errors
///
/// If `account_info` does not have the same ID as the sysvar
/// this function returns [`ProgramError::InvalidArgument`].
fn from_account_info(account_info: &AccountInfo) -> Result<Self, ProgramError> {
if !Self::check_id(account_info.unsigned_key()) {
return Err(ProgramError::InvalidArgument);