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 3, 2024
1 parent bd607e6 commit af0f7d0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 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"] }
15 changes: 15 additions & 0 deletions crates/json-ld/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ impl<'a> serde::Serialize for JsonLdTypes<'a> {
}
}

impl<'a> From<JsonLdTypes<'a>> for Vec<String> {
fn from(value: JsonLdTypes<'a>) -> Self {
let mut vec: Vec<String> = Vec::with_capacity(value.len());
vec.extend_from_slice(
&value
.static_
.into_iter()
.map(ToString::to_string)
.collect::<Vec<String>>(),
);
vec.extend(value.non_static.into_owned());
vec
}
}

pub struct WithContext<T> {
pub context: Option<json_ld::syntax::Context>,
pub value: T,
Expand Down

0 comments on commit af0f7d0

Please sign in to comment.