-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create Verifiable Credentials #5
Conversation
9ef5f3e
to
8abb8fa
Compare
8abb8fa
to
158a920
Compare
43ef7b3
to
ccd843c
Compare
ccd843c
to
faf7ea1
Compare
66a2141
to
1c73669
Compare
1c73669
to
cc4dcb1
Compare
c5edcc1
to
a922440
Compare
c1b8a8a
to
b15ce62
Compare
core/src/credential.rs
Outdated
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
#[serde(bound(deserialize = "'de: 'static"))] | ||
pub struct VerifiableCredential { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a #[serde(rename_all = "camelCase")]
header for the struct whilst keeping explicit fields with their own renames (such as id). Here's an example
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
#[serde(bound(deserialize = "'de: 'static"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we can't suppress this warning yet:
rust-lang/rust#96956
Once that's merged into main we can add #[allow(needless_lifetimes)]
here
For now, let's add a comment linking to this post:
https://users.rust-lang.org/t/restrict-generic-type-to-static-lifetime/16915/4
The borrow checker currently isn't smart enough to reason around 'de: 'static
bounds.
@LuisOsta @sKudryashov LMK if you have any questions about the two links above
#[serde(rename = "@id")] | ||
id: String, | ||
#[serde(rename = "type")] | ||
cred_type: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you wanted to keep a field name of type, you could call it r#type: String,
it will look weird but this way you can explicitly have the field named self.r#type
if you'd like
EDIT: not saying you should, it all depends on how explicit you want the struct to json analogue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is a great trick, since the type
word is reserved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep it as is so far but thank you for introducing it, it is definitely good for the similar situations in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@sKudryashov we can follow up with suggested changes in a separate PR. The comment section shouldn't hit triple digits 😓
@LuisOsta any concerns about merging as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkatychev @sKudryashov There's a couple of issues but apart from them I'm happy to approve this PR
5c5e4a6
to
df2bada
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nit remaining but looks good to me overall
core/src/credential.rs
Outdated
#[serde(bound(deserialize = "'de: 'static"))] | ||
pub struct VerifiableCredential { | ||
#[serde(flatten)] | ||
verifiable_credential:Credential, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be credential
df2bada
to
866f7b3
Compare
Implements https://www.notion.so/Create-Integrate-Core-SSI-Rust-Library-Design-9eb9e58093a04a7d84bb476ac0324a7d#a966c7269600446698ecdeea81886afc