Skip to content

Commit

Permalink
Add serialization for usize as string in StatusList2021Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyaasir committed Nov 12, 2024
1 parent 6f83696 commit ac9d2ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion identity_credential/src/revocation/status_list_2021/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ where
.map(ToOwned::to_owned)
}

/// Serialize usize as string.
fn serialize_number_as_string<S>(value: &usize, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(&value.to_string())
}

/// [StatusList2021Entry](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021entry) implementation.
#[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
Expand All @@ -45,7 +53,10 @@ pub struct StatusList2021Entry {
#[serde(rename = "type", deserialize_with = "deserialize_status_entry_type")]
type_: String,
status_purpose: StatusPurpose,
#[serde(deserialize_with = "serde_aux::prelude::deserialize_number_from_string")]
#[serde(
deserialize_with = "serde_aux::prelude::deserialize_number_from_string",
serialize_with = "serialize_number_as_string"
)]
status_list_index: usize,
status_list_credential: Url,
}
Expand Down

0 comments on commit ac9d2ed

Please sign in to comment.