Skip to content

Commit

Permalink
Move main package to workspace's toplevel.
Browse files Browse the repository at this point in the history
Bump `rdf-types` to version 0.22.0
Update `README.md` (add badges)
Add CI workflow.
  • Loading branch information
timothee-haudebourg committed Mar 22, 2024
1 parent 1ad96c2 commit 2afead7
Show file tree
Hide file tree
Showing 42 changed files with 912 additions and 970 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Continuous Integration

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLORS: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Retrieve MSRV
id: msrv
run: echo "MSRV=$(cat Cargo.toml | grep -Po '(?<=rust-version = ")([\d\.]+)')" >> $GITHUB_OUTPUT
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.msrv.outputs.MSRV }}
- name: Build
run: cargo build --all-features --verbose
- name: Run tests
run: cargo test --all-features --verbose

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings
41 changes: 37 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
[package]
name = "linked-data"
authors = ["Spruce Systems, Inc."]
license = "MIT/Apache-2.0"
description = "Linked-Data dateset serialization/deserialization traits"
categories = ["encoding", "web-programming"]
keywords = ["semantic-web", "linked-data", "rdf", "serialization"]
repository = "https://github.com/spruceid/linked-data-rs"
edition = "2021"
rust-version = "1.71.1"
version = "0.1.0"

[features]
default = ["derive", "serde"]
derive = ["linked-data-derive"]

[dependencies]
rdf-types = "0.22.0"
xsd-types = "0.9.2"
static-iref = "3.0"
json-syntax = { version = "0.12.2", features = ["canonicalize"] }
educe = "0.4.22"
im = "15.1.0"
iref.workspace = true
thiserror.workspace = true
linked-data-derive = { workspace = true, optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
json-syntax = { version = "0.12.2", features = ["serde"] }

[[example]]
name = "derive"
required-features = ["derive"]

[workspace]
members = [
"linked-data",
"linked-data-derive"
"derive"
]

resolver = "2"

[workspace.dependencies]
linked-data = { version = "0.1", path = "linked-data" }
linked-data-derive = { version = "0.1", path = "linked-data-derive" }
linked-data-derive = { version = "0.1", path = "derive" }
iref = "3.0"
static-iref = "3.0"
thiserror = "1.0.47"
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Linked-Data serialization and deserialization primitives

[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/spruceid/linked-data-rs/ci.yml?style=flat-square&logo=github)](https://github.com/spruceid/linked-data-rs/actions)
[![Crate informations](https://img.shields.io/crates/v/linked-data.svg?style=flat-square)](https://crates.io/crates/linked-data)
[![Crates.io MSRV](https://img.shields.io/crates/msrv/linked-data?style=flat-square)](https://crates.io/crates/linked-data)
[![License](https://img.shields.io/crates/l/linked-data.svg?style=flat-square)](https://github.com/spruceid/linked-data-rs#license)
[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://docs.rs/linked-data)

<!-- cargo-rdme start -->

This library provides primitive traits to serialize and deserialize
Expand All @@ -11,9 +17,8 @@ feature) that can automatically implement those primitives for you.
```rust
use iref::IriBuf;
use static_iref::iri;
use linked_data::LinkedData;

#[derive(LinkedData)]
#[derive(linked_data::Serialize, linked_data::Deserialize)]
#[ld(prefix("ex" = "http://example.org/"))]
struct Foo {
#[ld(id)]
Expand All @@ -32,7 +37,9 @@ let value = Foo {
email: "[email protected]".to_owned()
};

let quads = linked_data::to_quads(rdf_types::generator::Blank::new(), &value).expect("RDF serialization failed");
let quads = linked_data::to_quads(rdf_types::generator::Blank::new(), &value)
.expect("RDF serialization failed");

for quad in quads {
use rdf_types::RdfDisplay;
println!("{} .", quad.rdf_display())
Expand All @@ -46,3 +53,18 @@ This should print the following:
```

<!-- cargo-rdme end -->

## License

Licensed under either of

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.
60 changes: 60 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
"""

body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- [{{ commit.id | truncate(length=7, end="") }}] {{ commit.message }}\
{% endfor %}
{% endfor %}\n
"""
# Remove the leading and trailing whitespace.
trim = true

[git]
# Ignore conventional commits.
conventional_commits = false
filter_unconventional = false

# Process each line of a commit as an individual commit.
split_commits = true

# Regex for parsing and grouping commits.
commit_parsers = [
{ message = "^[aA]dd( |ed)", group = "Added"},
{ message = "^[iI]mpl", group = "Added"},
{ message = "^[fF]ix( |ed)", group = "Fixed"},
{ message = "^[cC]hange( |ed)", group = "Changed"},
{ message = "^[mM]ove( |d)", group = "Changed"},
{ message = "^[rR]estructure( |d)", group = "Changed"},
{ message = "^[rR]efactor( |ed)", group = "Changed"},
{ message = "^[rR]emove( |d)", group = "Removed"},
{ message = "^[uU]pgrade( |d)", group = "Build"},
{ message = "^[bB]ump( |ed)", group = "Build"}
]

# Protect breaking changes from being skipped due to matching a skipping commit_parser.
protect_breaking_commits = false

# Filter out the commits that are not matched by commit parsers.
filter_commits = true

# Glob pattern for matching git tags
tag_pattern = "[0-9\\.]*"

# Sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions linked-data-derive/src/generate.rs → derive/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl ToTokens for VocabularyBounds {

if self.iri_mut {
tokens.extend(quote! {
+ ::linked_data::rdf_types::IriVocabularyMut
+ ::linked_data::rdf_types::vocabulary::IriVocabularyMut
})
}
}
Expand All @@ -153,7 +153,7 @@ impl ToTokens for InterpretationBounds {

if self.iri_mut {
tokens.extend(quote! {
+ ::linked_data::rdf_types::IriInterpretation<V_::Iri>
+ ::linked_data::rdf_types::interpretation::IriInterpretation<V_::Iri>
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn generate_field(
interpretation_,
dataset_,
graph_,
<D_::Graph as ::linked_data::grdf::Graph>::objects(graph_, resource_, &predicate_),
::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate_),
context_
)?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn generate(
interpretation_,
dataset_,
graph_,
<D_::Graph as ::linked_data::grdf::Graph>::objects(graph_, resource_, &predicate),
::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate),
context_
);

Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn generate(
quote! {
match vocabulary_.get(unsafe { ::linked_data::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
Some(predicate) => {
let mut objects = <D_::Graph as ::linked_data::grdf::Graph>::objects(graph_, resource_, &predicate);
let mut objects = ::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate);

let result = match objects.next() {
Some(resource_) => {
Expand Down Expand Up @@ -125,7 +125,14 @@ pub fn generate(
}
}
None => match variant_shape(&v.fields) {
VariantShape::Simple(_ty) => {
VariantShape::Simple(ty) => {
bounds.push(
syn::parse2(
quote!(#ty: ::linked_data::LinkedDataDeserializeSubject<I_, V_>),
)
.unwrap(),
);

quote! {
let result = ::linked_data::LinkedDataDeserializeSubject::deserialize_subject_in(
vocabulary_,
Expand All @@ -137,7 +144,7 @@ pub fn generate(
);

match result {
Ok(value) => return Ok(value),
Ok(value) => return Ok(Self::#v_ident(value)),
Err(e) => error = Some(e)
}
}
Expand Down Expand Up @@ -182,12 +189,12 @@ pub fn generate(
vocabulary_: &V_,
interpretation_: &I_,
dataset_: &D_,
graph_: &D_::Graph,
graph_: Option<&I_::Resource>,
resource_: &I_::Resource,
outer_context_: ::linked_data::Context<I_>
) -> Result<Self, ::linked_data::FromLinkedDataError>
where
D_: ::linked_data::grdf::Dataset<Subject = I_::Resource, Predicate = I_::Resource, Object = I_::Resource, GraphLabel = I_::Resource>
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
{
let context_ = outer_context_.with_subject(resource_);
let mut error = None;
Expand All @@ -210,13 +217,13 @@ pub fn generate(
vocabulary: &V_,
interpretation: &I_,
dataset: &D_,
graph: &D_::Graph,
graph: Option<&I_::Resource>,
objects: impl IntoIterator<Item = &'de_ I_::Resource>,
context: ::linked_data::Context<I_>
) -> Result<Self, ::linked_data::FromLinkedDataError>
where
I_::Resource: 'de_,
D_: ::linked_data::grdf::Dataset<Subject = I_::Resource, Predicate = I_::Resource, Object = I_::Resource, GraphLabel = I_::Resource>
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
{
let mut objects = objects.into_iter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ pub fn generate(
vocabulary_: &V_,
interpretation_: &I_,
dataset_: &D_,
graph_: &D_::Graph,
graph_: Option<&I_::Resource>,
resource_: &I_::Resource,
context_: ::linked_data::Context<I_>
) -> Result<Self, ::linked_data::FromLinkedDataError>
where
D_: ::linked_data::grdf::Dataset<Subject = I_::Resource, Predicate = I_::Resource, Object = I_::Resource, GraphLabel = I_::Resource>
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
{
let context_ = context_.with_subject(resource_);
#(#deserialize_fields)*
Expand All @@ -49,13 +49,13 @@ pub fn generate(
vocabulary: &V_,
interpretation: &I_,
dataset: &D_,
graph: &D_::Graph,
graph: Option<&I_::Resource>,
objects: impl IntoIterator<Item = &'de_ I_::Resource>,
context: ::linked_data::Context<I_>
) -> Result<Self, ::linked_data::FromLinkedDataError>
where
I_::Resource: 'de_,
D_: ::linked_data::grdf::Dataset<Subject = I_::Resource, Predicate = I_::Resource, Object = I_::Resource, GraphLabel = I_::Resource>
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
{
let mut objects = objects.into_iter();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions linked-data/Cargo.toml

This file was deleted.

Loading

0 comments on commit 2afead7

Please sign in to comment.