Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait SessionKind {
- type CreatorRelatedType;
- }
- trait ServerSessionKind: SessionKind {
- type CreatorRelatedType: AbstractCreatorType;
- }
- trait AbstractCreatorType {}
- trait FinalizedSessionKind: SessionKind {
- type CreatorRelatedType: ConcreteCreatorType;
- }
- trait ConcreteCreatorType {}
- trait SessionV1Kind: SessionKind {}
- trait ServerSessionV1Kind: SessionV1Kind + ServerSessionKind {}
- trait SessionV2Kind: SessionKind {}
- trait ServerSessionV2Kind: SessionV2Kind + ServerSessionKind {}
- enum Session<T: SessionKind> {
- V1(SessionV1<T>),
- V2(SessionV2<T>)
- }
- struct SessionV2<T: SessionV2Kind> {
- _pd: std::marker::PhantomData<T>,
- }
- struct SessionV1<T: SessionV1Kind> {
- some_field_depending_on_session_kind: SomeV1FieldType<T>,
- }
- struct SomeV1FieldType<T: SessionV1Kind> {
- some_unrelated_field: u64,
- some_session_kind_related_field: T::CreatorRelatedType,
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement