Skip to content

Commit

Permalink
Feat/add json ld types to vec string (#629)
Browse files Browse the repository at this point in the history
* use array as preferred for credential types

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Co-Authored-By: Joey Silberman <joey.silberman@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* Update crates/claims/crates/vc/Cargo.toml

* add conversion for json ld types to vec string

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* Update crates/json-ld/Cargo.toml

---------

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Co-authored-by: Joey Silberman <joey.silberman@spruceid.com>
  • Loading branch information
Ryanmtate and Joey-Silberman authored Dec 11, 2024
1 parent 6e7b3b1 commit 3b57c43
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/json-ld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ pub trait Expandable: Sized {

impl Expandable for CompactJsonLd {
type Error = JsonLdError;
type Expanded<I, V> = json_ld::ExpandedDocument<V::Iri, V::BlankId>
type Expanded<I, V>
= json_ld::ExpandedDocument<V::Iri, V::BlankId>
where
I: Interpretation,
V: VocabularyMut,
Expand Down Expand Up @@ -225,6 +226,15 @@ impl<'a> serde::Serialize for JsonLdTypes<'a> {
}
}

impl<'a> From<JsonLdTypes<'a>> for Vec<String> {
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<T> {
pub context: Option<json_ld::syntax::Context>,
pub value: T,
Expand Down

0 comments on commit 3b57c43

Please sign in to comment.