default.txt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. @0xdbb9ad1f14bf0b36; # unique file ID, generated by `capnp id`
  2. struct Person {
  3. name @0 :Text;
  4. birthdate @3 :Date;
  5. email @1 :Text;
  6. phones @2 :List(PhoneNumber);
  7. struct PhoneNumber {
  8. number @0 :Text;
  9. type @1 :Type;
  10. enum Type {
  11. mobile @0;
  12. home @1;
  13. work @2;
  14. }
  15. }
  16. }
  17. struct Date {
  18. year @0 :Int16;
  19. month @1 :UInt8;
  20. day @2 :UInt8;
  21. flags @3 :List(Bool) = [ true, false, false, true ];
  22. }
  23. interface Node {
  24. isDirectory @0 () -> (result :Bool);
  25. }
  26. interface Directory extends(Node) {
  27. list @0 () -> (list: List(Entry));
  28. struct Entry {
  29. name @0 :Text;
  30. node @1 :Node;
  31. }
  32. create @1 (name :Text) -> (file :File);
  33. mkdir @2 (name :Text) -> (directory :Directory)
  34. open @3 (name :Text) -> (node :Node);
  35. delete @4 (name :Text);
  36. link @5 (name :Text, node :Node);
  37. }
  38. interface File extends(Node) {
  39. size @0 () -> (size: UInt64);
  40. read @1 (startAt :UInt64 = 0, amount :UInt64 = 0xffffffffffffffff)
  41. -> (data: Data);
  42. # Default params = read entire file.
  43. write @2 (startAt :UInt64, data :Data);
  44. truncate @3 (size :UInt64);
  45. }