identity_credential/credential/
status.rs1use serde::Deserialize;
5use serde::Serialize;
6
7use identity_core::common::Object;
8use identity_core::common::Url;
9
10#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
14pub struct Status<T = Object> {
15 pub id: Url,
17 #[serde(rename = "type")]
19 pub type_: String,
20 #[serde(flatten)]
22 pub properties: T,
23}
24
25impl Status<Object> {
26 pub fn new(id: Url, type_: String) -> Self {
28 Self::new_with_properties(id, type_, Object::new())
29 }
30}
31
32impl<T> Status<T> {
33 pub fn new_with_properties(id: Url, type_: String, properties: T) -> Self {
35 Self { id, type_, properties }
36 }
37}
38
39#[cfg(test)]
40mod tests {
41 use identity_core::convert::FromJson;
42
43 use super::*;
44
45 const JSON: &str = include_str!("../../tests/fixtures/status-1.json");
46
47 #[test]
48 fn test_from_json() {
49 let status: Status = Status::from_json(JSON).unwrap();
50 assert_eq!(status.id.as_str(), "https://example.edu/status/24");
51 assert_eq!(status.type_, "CredentialStatusList2017");
52 }
53}