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

Add 'Any' type for JSON serializable types #131

Closed
wants to merge 1 commit into from

Conversation

KendallWeihe
Copy link
Contributor

Originated from this PR #130

We have needs for a general "any" type. The intent here is to create a solution which is compatible both in a pure rust development environment but also in a UniFFI binding project.

There is a question of: "should we place this in bindings/uniffi instead? because it seems to be a constraint specific to UniFFI"

The problem is on this line in web5.udl

interface VerifiableCredential {
  constructor(sequence<string> context, string id, sequence<string> type, string issuer, i64 issuance_date, i64? expiration_date, CredentialSubject credential_subject);

From @decentralgabe's comment here:

  1. Pure native rust (with generics)
  2. Bindings (with optional translation code to make the bindings nice)
  3. Consumption of bindings
  4. Idiomatic API surface in target language

I have had a stretch goal of limiting the burden on layer (2) to solely associated functions because leveraging the constructor feature in UDL means the binded language can do a traditional VerifiableCredential(...params). But in order for us to leverage the constructor feature, the crates/credentials/src/vc.rs would have to inline the Any type in it's code. And if Any lives in bindings/uniffi crate then that means our core crate now has a dependency on the UniFFI bindings crate. Which is no bueno.

All of this to say, bindings really turns us into a pretzel. This PR is intended to spur discovery, we may choose to decline merging this. We need to establish patterns which are repeatable.

@KendallWeihe
Copy link
Contributor Author

So to be clear, the alternative could be to place this Any inside of the bindings/uniffi crate, and instead of this UDL code (added ... for readability, not actually valid code)

interface VerifiableCredential {
  constructor(...);

We would add this

namespace web5 {
  VerifiableCredential new_verifiable_credential(..., evidence: Any);

@KendallWeihe KendallWeihe marked this pull request as draft April 24, 2024 21:25
@KendallWeihe
Copy link
Contributor Author

I have to write the full code to showcase the alternative. Doing so now. Moved this to a draft stage.

Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - cool to prove this out

@KendallWeihe KendallWeihe deleted the kendall/any-crate branch July 10, 2024 19:35
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 this pull request may close these issues.

2 participants