Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. ### Storage Engine
  2.  
  3. A general storage engine, not sure what to pick as the interface
  4.  
  5. Simpler:
  6. ```rust
  7. pub trait StorageEngine { fn store<T: RustcEncodable>(&mut self, t: T); }
  8. ```
  9.  
  10. Probably better?
  11. ```rust
  12. pub type PrimaryKey = &[u8];
  13. pub type SerializedRecord = &[u8];
  14.  
  15. pub trait StorageEngine {
  16. fn store<T: Storable>(&mut self, t: T) -> ConstableResult<()>;
  17. }
  18.  
  19. pub trait Storable {
  20. fn get_primary_key(&self) -> PrimaryKey;
  21. fn to_binary(&self) -> SerializedRecord;
  22. fn from_binary(record: SerializedRecord) -> Self;
  23. }
  24. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement