From 3b57c43f0bc3ba0374588c4bd3327b10f7eee989 Mon Sep 17 00:00:00 2001 From: Ryan Tate Date: Wed, 11 Dec 2024 10:32:58 -0800 Subject: [PATCH] Feat/add json ld types to vec string (#629) * use array as preferred for credential types Signed-off-by: Ryan Tate Co-Authored-By: Joey Silberman Signed-off-by: Ryan Tate * Update crates/claims/crates/vc/Cargo.toml * add conversion for json ld types to vec string Signed-off-by: Ryan Tate * Update crates/json-ld/Cargo.toml --------- Signed-off-by: Ryan Tate Co-authored-by: Joey Silberman --- crates/json-ld/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/json-ld/src/lib.rs b/crates/json-ld/src/lib.rs index 327275029..b761d6b20 100644 --- a/crates/json-ld/src/lib.rs +++ b/crates/json-ld/src/lib.rs @@ -85,7 +85,8 @@ pub trait Expandable: Sized { impl Expandable for CompactJsonLd { type Error = JsonLdError; - type Expanded = json_ld::ExpandedDocument + type Expanded + = json_ld::ExpandedDocument where I: Interpretation, V: VocabularyMut, @@ -225,6 +226,15 @@ impl<'a> serde::Serialize for JsonLdTypes<'a> { } } +impl<'a> From> for Vec { + fn from(value: JsonLdTypes<'a>) -> Self { + let mut result = Vec::with_capacity(value.len()); + result.extend(value.static_.iter().map(|s| s.to_string())); + result.extend(value.non_static.into_owned()); + result + } +} + pub struct WithContext { pub context: Option, pub value: T,