Skip to content

Commit

Permalink
add conversion for json ld types to vec string
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Dec 10, 2024
1 parent 29bd459 commit 43561f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/json-ld/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ssi-json-ld"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = ["Spruce Systems, Inc."]
license = "Apache-2.0"
Expand Down Expand Up @@ -31,4 +31,4 @@ serde.workspace = true
difference = "2.0"
nquads-syntax.workspace = true
serde_json.workspace = true
tokio = { version = "1.27.0", features = ["rt", "macros"] }
tokio = { version = "1.27.0", features = ["rt", "macros"] }
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 43561f0

Please sign in to comment.