Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. trait SessionKind {
  2. type CreatorRelatedType;
  3. }
  4.  
  5. trait ServerSessionKind: SessionKind {
  6. type CreatorRelatedType: AbstractCreatorType;
  7. }
  8.  
  9. trait AbstractCreatorType {}
  10.  
  11. trait FinalizedSessionKind: SessionKind {
  12. type CreatorRelatedType: ConcreteCreatorType;
  13. }
  14.  
  15. trait ConcreteCreatorType {}
  16.  
  17. trait SessionV1Kind: SessionKind {}
  18.  
  19. trait ServerSessionV1Kind: SessionV1Kind + ServerSessionKind {}
  20.  
  21. trait SessionV2Kind: SessionKind {}
  22.  
  23. trait ServerSessionV2Kind: SessionV2Kind + ServerSessionKind {}
  24.  
  25. enum Session<T: SessionKind> {
  26. V1(SessionV1<T>),
  27. V2(SessionV2<T>)
  28. }
  29.  
  30. struct SessionV2<T: SessionV2Kind> {
  31. _pd: std::marker::PhantomData<T>,
  32. }
  33.  
  34. struct SessionV1<T: SessionV1Kind> {
  35. some_field_depending_on_session_kind: SomeV1FieldType<T>,
  36. }
  37.  
  38. struct SomeV1FieldType<T: SessionV1Kind> {
  39. some_unrelated_field: u64,
  40. some_session_kind_related_field: T::CreatorRelatedType,
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement