[][src]Struct caelum_vcdm::VCredential

pub struct VCredential { /* fields omitted */ }

Methods

impl VCredential[src]

pub fn new(id: String) -> Self[src]

Web assembly Constructor

VCredential's constructor will create an empty VCredential object. An empty object is not a valid VCredential.

pub fn from_json(json: JsValue) -> Self[src]

WebAssembly Constructor formJSON

VCredential's constructor will create a VCredential object from input. Input must be a JSON object with all properties defined. If no value is wanted for certain property, must be empty. This is also true for sub properties (properties of properties).

pub fn set_context(self, c: String) -> Self[src]

Set context

By default context will be set to

{
    context: [
        "https://www.w3.org/2018/credentials/v1",
        "https://www.w3.org/2018/credentials/examples/v1"
    ]
}

To overwrite default contexts use method setContext() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setContext("new_context");

pub fn set_type(self, t: String) -> Self[src]

Set Type

By default type will be set to

{
    type: [
        "VerifiableCredential",
        "PersonalInformation"
    ]
}

To overwrite default types use method setType() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setType("new_type");

pub fn set_id(self, id: String) -> Self[src]

Set Id

By default id will be set by the constructor. To overwrite default id use method setId() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setId("my_id");

pub fn set_issuer(self, i: String) -> Self[src]

Set Issuer

By default issuer will be set to empty. To overwrite default issuer use method setIssuer() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setIssuer("my_issuer");

pub fn set_claims(self, c: JsValue) -> Self[src]

Set Claim

By default claims will be set to empty array. To overwrite default claims use method setClaims() can be used.

import { VCredential } from 'caelum_vcdm';

pub fn set_proof(self, p: JsValue) -> Self[src]

Set Proof

By default proof will be set to empty. To overwrite default proof use method setProof() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setProof({
       "type": "RsaSignature2018",
       "created": "2018-06-17T10:03:48Z",
       "verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
       "signatureValue": "pY9...Cky6Ed = "
   });

pub fn set_non_revocation_proof(self, p: JsValue) -> Self[src]

Set NonRevocationProof

By default nonRevocationProof will be set to empty. To overwrite default nonRevocationProof use method setNonRevocationProof() can be used.

import { VCredential } from 'caelum_vcdm';

pub fn add_context(self, c: String) -> Self[src]

Add context

By default context will be set to

{
    context: [
        "https://www.w3.org/2018/credentials/v1",
        "https://www.w3.org/2018/credentials/examples/v1"
    ]
}

To add to the default context array use method addContext() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .addContext("another_context");

pub fn add_claim(self, c: JsValue) -> Self[src]

Add Claim

To add to the default claims array use method addClaim() can be used.

import { VCredential } from 'caelum_vcdm';

pub fn add_proof(self, p: JsValue) -> Self[src]

Add Proof

By default proof will be set to an empty Vec::new(). To overwrite default proof use method addProof() can be used.

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .addProof({
       "type": "RsaSignature2018",
       "created": "2018-06-17T10:03:48Z",
       "verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
       "signatureValue": "pY9...Cky6Ed = "
   });

pub fn add_non_revocation_proof(self, p: JsValue) -> Self[src]

Add NonRevocationProof

By default monRevocationProof will be set to an empty Vec::new(). To overwrite default nonRevocationProof use method addNonRevocationProof() can be used.

import { VCredential } from 'caelum_vcdm';

pub fn add_type(self, t: String) -> Self[src]

Add Type

By default type will be set to:

{
    type: [
        "VerifiableCredential",
        "PersonalInformation"
    ]
}

Once a property type is set, one may want to add to the array. To do so use method addType().

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .addType("new_type");

pub fn get_context(&self) -> JsValue[src]

Get Context

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
console.log(vc.getContext())

The code above will print in console the following:

{
    context: [
        "https://www.w3.org/2018/credentials/v1",
        "https://www.w3.org/2018/credentials/examples/v1"
    ]
}

pub fn get_type(&self) -> JsValue[src]

Get Type

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setType({id: "my_id", type: "my_type"})
console.log(vc.getType())

The code above will print in console the following:

{
    id: "my_id",
    type: "my_type"
}

pub fn get_id(&self) -> JsValue[src]

Get Id

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id");
console.log(vc.getId())

The code above will print in console the following:

id: "my_id"

pub fn get_issuer(&self) -> JsValue[src]

Get Issuer

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setIssuanceDate("2018-06-17T10:03:48Z"})
console.log(vc.getIssuanceDate())

The code above will print in console the following:

"2018-06-17T10:03:48Z"

pub fn get_claims(&self) -> JsValue[src]

Get Claims

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setIssuanceDate("2018-06-17T10:03:48Z"})
console.log(vc.getIssuanceDate())

The code above will print in console the following:

"2018-06-17T10:03:48Z"

pub fn get_proof(&self) -> JsValue[src]

Get Proof

import { VCredential } from 'caelum_vcdm';
let vc = new VCredential("my_id")
    .setProof({
       "type": "RsaSignature2018",
       "created": "2018-06-17T10:03:48Z",
       "verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
       "signatureValue": "pY9...Cky6Ed = "
    })
console.log(vc.getProof())

The code above will print in console the following:

[{
    "type": "RsaSignature2018",
    "created": "2018-06-17T10:03:48Z",
    "verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
    "signatureValue": "pY9...Cky6Ed = "
}]

pub fn get_non_revocation_proof(&self) -> JsValue[src]

Get NonRevocationProof

import { VCredential } from 'caelum_vcdm';
```json
[{
    "type": "RsaSignature2018",
    "created": "2018-06-17T10:03:48Z",
    "verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
    "signatureValue": "pY9...Cky6Ed = "
}]

pub fn to_json(&self) -> JsValue[src]

Jsonify Verifiable Credential

toJSON method will output the current VCredential as a JsValue (json object).

Trait Implementations

impl From<VCredential> for JsValue[src]

impl RefFromWasmAbi for VCredential[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

type Anchor = Ref<'static, VCredential>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more

impl FromWasmAbi for VCredential[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

impl IntoWasmAbi for VCredential[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl WasmDescribe for VCredential[src]

impl OptionFromWasmAbi for VCredential[src]

impl OptionIntoWasmAbi for VCredential[src]

impl RefMutFromWasmAbi for VCredential[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, VCredential>

Same as RefFromWasmAbi::Anchor

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Same<T> for T

type Output = T

Should always be Self