rebase/content/delegated_attestation/
delegated_like_attestation.rs1use crate::types::{defs::Content, error::ContentError};
2use async_trait::async_trait;
3use serde::{Deserialize, Serialize};
4use serde_json::json;
5use ssi::{one_or_many::OneOrMany, vc::Evidence};
6use tsify::Tsify;
7use url::Url;
8use wasm_bindgen::prelude::*;
9
10#[derive(Debug, Deserialize, Serialize, Tsify, Clone)]
11#[tsify(into_wasm_abi, from_wasm_abi)]
12pub struct DelegatedLikeAttestationContent {
13 pub id: String,
14 pub target: Url,
15 pub delegate: String,
16}
17
18#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
19#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
20impl Content for DelegatedLikeAttestationContent {
21 fn context(&self) -> Result<serde_json::Value, ContentError> {
22 Ok(json!([
23 "https://www.w3.org/2018/credentials/v1",
24 "https://spec.rebase.xyz/contexts/v1",
25 "https://schema.org/"
26 ]))
27 }
28
29 fn types(&self) -> Result<Vec<String>, ContentError> {
30 Ok(vec![
31 "VerifiableCredential".to_string(),
32 "DelegatedLikeAttestation".to_string(),
33 ])
34 }
35
36 fn subject(&self) -> Result<serde_json::Value, ContentError> {
37 Ok(json!({
38 "id": self.id,
39 "target": self.target,
40 "delegate": self.delegate,
41 "type": ["DelegatedLikeAttestation"],
42 }))
43 }
44
45 fn evidence(&self) -> Result<Option<OneOrMany<Evidence>>, ContentError> {
46 Ok(None)
47 }
48}