Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aries-VCX/Typestate Connection #740

Closed
bobozaur opened this issue Jan 24, 2023 · 0 comments · Fixed by #739
Closed

Aries-VCX/Typestate Connection #740

bobozaur opened this issue Jan 24, 2023 · 0 comments · Fixed by #739
Assignees

Comments

@bobozaur
Copy link
Contributor

Use Rust's typestate pattern for the Connection type.

Advantages:

  • Compile time guarantees that the state machine cannot get into an invalid state.
  • Better performance by greatly decreasing condition checking.
  • Less and cleaner code (due to less nesting and more specialization)

Disadvantages:

  • The state machine transitions from one type to another. Storing all of them in a container would require either conversion to/from a common type or other approaches such as Box<dyn Any> and downcasting.

Additional Goals:

Besides the advantages mentioned above, the linked PR will target a more thorough analysis and refactor of the overall Connection functionalities and aims to:

  • deduplicate code
  • handle memory better by a stricter use of clones (right now they're all over the place)
  • comment structs and methods

Other ideas:

  • Restrict a spawned connection to only a certain type of transport (HTTP, Websockets, SSH, etc.)? Should it be allowed for a Connection that's been used over some transport, e.g. HTTP, to switch to a different one? I'd say that should require a different Connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant