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

Handlers are missing a alternative forms of construction (from_parts) #742

Open
gmulhearn-anonyome opened this issue Feb 2, 2023 · 2 comments

Comments

@gmulhearn-anonyome
Copy link
Contributor

The MediatedConnection handler has a public from_parts API, which allows consumers to reconstruct their MediatedConnection objects with typed data.

This is useful to consumers who have data representing a 'mediatedconnection' in another form (e.g. they are coming from another lib, or they are internally storing 'connections' in their own format).

from_parts allows consumers to not depend on the exact format/result of serializing/deserializing the handler (which may change over time, especially with the recently proposed typestate patterns).

However other handlers - Connection, Prover, Verifier, Holder, Issuer don't have such a function, and the only way to reconstruct them is by serializing and deserializing. So if you want to reconstruct them, and you don't have a serializing version of the handler, your only option is to hackily recreate the serializing format with your own data and try deserialising it...

So i'd propose that, like MediatedConnection, handlers should have an alternative (re-)constructor method such as from_parts. In making this method, we'd need to ensure that consumers can publicly access ways to construct the 'parts' they need.
E.g. for Connection::from_parts(..., state: SmConnectionState), we'd need to ensure that consumers can construct the SmConnectionState object virtually from scratch - which I believe is already the case, but just pointing it out.

Alternatively, we could make the fields of handlers all public, but IMO from_parts constructors would be cleaner.

@gmulhearn-anonyome
Copy link
Contributor Author

Let me know if you agree or disagree with this proposal - was there a reason that all other handlers are missing the from_parts constructor? I will start working on an PR for Connection handler in the meantime

@gmulhearn-anonyome
Copy link
Contributor Author

Update; from the meeting last week, we agreed to include from_parts and to_parts operators in handlers. These were added to Connection with the typestate MR #740 . However other handlers are still missing them

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

No branches or pull requests

1 participant