identity_credential/credential/
status.rsuse serde::Deserialize;
use serde::Serialize;
use identity_core::common::Object;
use identity_core::common::Url;
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
pub struct Status<T = Object> {
pub id: Url,
#[serde(rename = "type")]
pub type_: String,
#[serde(flatten)]
pub properties: T,
}
impl Status<Object> {
pub fn new(id: Url, type_: String) -> Self {
Self::new_with_properties(id, type_, Object::new())
}
}
impl<T> Status<T> {
pub fn new_with_properties(id: Url, type_: String, properties: T) -> Self {
Self { id, type_, properties }
}
}
#[cfg(test)]
mod tests {
use identity_core::convert::FromJson;
use super::*;
const JSON: &str = include_str!("../../tests/fixtures/status-1.json");
#[test]
fn test_from_json() {
let status: Status = Status::from_json(JSON).unwrap();
assert_eq!(status.id.as_str(), "https://example.edu/status/24");
assert_eq!(status.type_, "CredentialStatusList2017");
}
}