main.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. mod serde_blocktree;
  2. use std::collections::{hash_map, HashMap};
  3. #[allow(dead_code)]
  4. enum VersionedBlock {
  5. V0(Block)
  6. }
  7. #[allow(dead_code)]
  8. struct Block {
  9. path: String,
  10. read_caps: HashMap<Hash, ReadCap>,
  11. write_cap: WriteCap,
  12. body: Vec<u8>,
  13. signature: Signature
  14. }
  15. #[allow(dead_code)]
  16. struct ReadCap {
  17. issued_to: Hash,
  18. key: EnvelopedKey,
  19. }
  20. #[allow(dead_code)]
  21. struct WriteCap {
  22. issued_to: Hash,
  23. path: String,
  24. chain: Vec<Certificate>,
  25. signature: Signature,
  26. }
  27. #[allow(dead_code)]
  28. struct Certificate {
  29. issued_to: Hash,
  30. issued_by: Hash,
  31. signature: Signature,
  32. }
  33. #[allow(dead_code)]
  34. enum Hash {
  35. Sha2_256([u8; 32]),
  36. Sha2_512([u8; 64]),
  37. }
  38. #[allow(dead_code)]
  39. enum Signature {
  40. Ed25519([u8; 64]),
  41. }
  42. #[allow(dead_code)]
  43. enum EnvelopedKey {
  44. Xsalsa20Poly1305([u8; 32]),
  45. }
  46. type Directory = HashMap<String, Vec<FragmentRecord>>;
  47. trait IDirectory {
  48. fn file_names(&self) -> hash_map::Keys<'_, String, Vec<FragmentRecord>>;
  49. }
  50. impl IDirectory for Directory {
  51. fn file_names(&self) -> hash_map::Keys<'_, String, Vec<FragmentRecord>> {
  52. self.keys()
  53. }
  54. }
  55. #[allow(dead_code)]
  56. struct FragmentRecord {
  57. stored_by: Hash,
  58. serial: u32,
  59. }
  60. #[allow(dead_code)]
  61. struct Fragment {
  62. path: String,
  63. serial: u32,
  64. body: Vec<u8>,
  65. }
  66. fn main() {
  67. println!("Hello, world!");
  68. }