Refactor Storage Program (#3622)

* Refactor Storage Program

* Replace KeyedAccount trait with StorageAccount struct

* Implement State for Account, not StorageAccount

* Make State trait more generic

* Move validation check into function
This commit is contained in:
Sagar Dhawan
2019-04-04 12:01:09 -07:00
committed by GitHub
parent 1598a02a7a
commit 0b23af324b
5 changed files with 467 additions and 382 deletions

View File

@@ -45,6 +45,14 @@ impl Account {
executable: false,
}
}
pub fn deserialize_data<T: serde::de::DeserializeOwned>(&self) -> Result<T, bincode::Error> {
bincode::deserialize(&self.data)
}
pub fn serialize_data<T: serde::Serialize>(&mut self, state: &T) -> Result<(), bincode::Error> {
bincode::serialize_into(&mut self.data[..], state)
}
}
#[repr(C)]