@@ -7,14 +7,14 @@ use serde_json::Value;
7
7
type VCContext = [ String ] ;
8
8
9
9
pub ( crate ) const JSON_LD_CONTEXT : VCContext = [ "https://www.w3.org/2018/credentials/v1" , "https://www.w3.org/2018/credentials/examples/v1" ] ;
10
- pub ( crate ) const CRED_TYPE_PASSPORT : str = "Passport " ;
11
- pub ( crate ) const CRED_TYPE_DRIVER_LICENSE : str = "DriverLicense " ;
10
+ pub ( crate ) const CRED_TYPE_PERMANENT_RESIDENT_CARD : str = "PermanentResidentCard " ;
11
+ pub ( crate ) const CRED_TYPE_BANK_CARD : str = "BankCard " ;
12
12
13
13
type CredentialSubject = serde_json:: Value ;
14
14
15
15
enum CredType {
16
- Passport ( String ) ,
17
- DriverLicense ( String )
16
+ PermanentResidentCard ( String ) ,
17
+ BankCard ( String )
18
18
}
19
19
20
20
pub trait VCCredential {
@@ -28,7 +28,7 @@ impl VCCredential for VerifiableCredential<'_> {
28
28
self . cred_type = ""
29
29
}
30
30
fn getSubject ( & self ) -> String {
31
- self . cred_type = ""
31
+ self . subject = ""
32
32
}
33
33
fn getContext ( & self ) ->[ String ] {
34
34
return crate :: credential:: JSON_LD_CONTEXT
@@ -51,18 +51,18 @@ pub struct VerifiableCredential <'a> {
51
51
impl < ' a > VerifiableCredential < ' a > {
52
52
pub fn init ( cred_type : String , cred_subject : serde_json:: Value , issuer : & ' a str , id : & ' a str ) -> Self {
53
53
let ctype = match cred_type {
54
- CRED_TYPE_PASSPORT => {
55
- Some ( CredType :: Passport ( cred_type) )
54
+ CRED_TYPE_PERMANENT_RESIDENT_CARD => {
55
+ Some ( CredType :: PermanentResidentCard ( cred_type) )
56
56
} ,
57
- CRED_TYPE_DRIVER_LICENSE => {
58
- Some ( CredType :: DriverLicense ( cred_type) )
57
+ CRED_TYPE_BANK_CARD => {
58
+ Some ( CredType :: BankCard ( cred_type) )
59
59
} ,
60
60
_ => {
61
61
None
62
62
}
63
63
} ;
64
64
let s = Self {
65
- context : JSON_LD_CONTEXT ,
65
+ context : [ ] ,
66
66
id : String :: from ( id) ,
67
67
cred_type : ctype,
68
68
issuer : String :: from ( issuer) ,
@@ -77,9 +77,7 @@ impl <'a> VerifiableCredential <'a> {
77
77
proof_value : String :: default ( ) ,
78
78
} ,
79
79
} ;
80
- s. cred_type = s. getCredType ( ) ;
81
80
s. context = s. getContext ( ) ;
82
- s. subject = s. getSubject ( ) ;
83
81
84
82
return s;
85
83
}
0 commit comments