Skip to content

Commit 27fadb6

Browse files
chore: start linked-data-next crate
1 parent a497d69 commit 27fadb6

File tree

16 files changed

+184
-161
lines changed

16 files changed

+184
-161
lines changed

Cargo.toml

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "linked-data"
2+
name = "linked-data-next"
33
description = "Linked-Data dateset serialization/deserialization traits"
44
categories = ["encoding", "web-programming"]
55
keywords = ["semantic-web", "linked-data", "rdf", "serialization"]
@@ -11,16 +11,19 @@ rust-version.workspace = true
1111
version.workspace = true
1212

1313
[workspace.package]
14-
authors = ["Spruce Systems, Inc."]
14+
authors = [
15+
"Spruce Systems, Inc.",
16+
"Lum::invent",
17+
]
1518
license = "MIT/Apache-2.0"
16-
repository = "https://github.com/spruceid/linked-data-rs"
19+
repository = "https://github.com/luminvent/linked-data-rs"
1720
edition = "2021"
1821
rust-version = "1.71.1"
1922
version = "0.1.2"
2023

2124
[features]
2225
default = ["derive", "serde"]
23-
derive = ["linked-data-derive"]
26+
derive = ["linked-data-next-derive"]
2427

2528
[dependencies]
2629
rdf-types = "0.22.1"
@@ -31,7 +34,7 @@ educe = "0.4.22"
3134
im = "15.1.0"
3235
iref.workspace = true
3336
thiserror.workspace = true
34-
linked-data-derive = { workspace = true, optional = true }
37+
linked-data-next-derive = { workspace = true, optional = true }
3538
serde = { version = "1.0", features = ["derive"], optional = true }
3639

3740
[dev-dependencies]
@@ -49,7 +52,7 @@ members = [
4952
resolver = "2"
5053

5154
[workspace.dependencies]
52-
linked-data-derive = { version = "0.1.0", path = "derive" }
55+
linked-data-next-derive = { version = "0.1.0", path = "derive" }
5356
iref = "3.0"
5457
static-iref = "3.0"
55-
thiserror = "1.0.47"
58+
thiserror = "1.0.47"

derive/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "linked-data-derive"
2+
name = "linked-data-next-derive"
33
description = "Derive macros for the `linked-data` crate"
44
authors.workspace = true
55
license.workspace = true
@@ -18,4 +18,4 @@ quote = "1.0.33"
1818
proc-macro-error = "1.0.4"
1919
thiserror.workspace = true
2020
iref.workspace = true
21-
static-iref.workspace = true
21+
static-iref.workspace = true

derive/src/generate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ impl VocabularyBounds {
121121
impl ToTokens for VocabularyBounds {
122122
fn to_tokens(&self, tokens: &mut TokenStream) {
123123
tokens.extend(quote! {
124-
::linked_data::rdf_types::Vocabulary
124+
::linked_data_next::rdf_types::Vocabulary
125125
});
126126

127127
if self.iri_mut {
128128
tokens.extend(quote! {
129-
+ ::linked_data::rdf_types::vocabulary::IriVocabularyMut
129+
+ ::linked_data_next::rdf_types::vocabulary::IriVocabularyMut
130130
})
131131
}
132132
}
@@ -148,18 +148,18 @@ impl InterpretationBounds {
148148
impl ToTokens for InterpretationBounds {
149149
fn to_tokens(&self, tokens: &mut TokenStream) {
150150
tokens.extend(quote! {
151-
::linked_data::rdf_types::Interpretation
151+
::linked_data_next::rdf_types::Interpretation
152152
});
153153

154154
if self.iri_mut {
155155
tokens.extend(quote! {
156-
+ ::linked_data::rdf_types::interpretation::IriInterpretation<V_::Iri>
156+
+ ::linked_data_next::rdf_types::interpretation::IriInterpretation<V_::Iri>
157157
})
158158
}
159159

160160
if self.reverse_iri {
161161
tokens.extend(quote! {
162-
+ ::linked_data::rdf_types::interpretation::ReverseIriInterpretation<Iri = V_::Iri>
162+
+ ::linked_data_next::rdf_types::interpretation::ReverseIriInterpretation<Iri = V_::Iri>
163163
})
164164
}
165165
}

derive/src/generate/de.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,27 @@ fn generate_field(
120120

121121
bounds.push(
122122
syn::parse2(
123-
quote!(#ty: ::linked_data::LinkedDataDeserializePredicateObjects<I_, V_>),
123+
quote!(#ty: ::linked_data_next::LinkedDataDeserializePredicateObjects<I_, V_>),
124124
)
125125
.unwrap(),
126126
);
127127

128128
Ok(Some(quote! {
129-
match vocabulary_.get(unsafe { ::linked_data::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
129+
match vocabulary_.get(unsafe { ::linked_data_next::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
130130
Some(predicate_) => {
131131
let context_ = context_.with_predicate(&predicate_);
132-
::linked_data::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
132+
::linked_data_next::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
133133
vocabulary_,
134134
interpretation_,
135135
dataset_,
136136
graph_,
137-
::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate_),
137+
::linked_data_next::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate_),
138138
context_
139139
)?
140140
}
141141
None => {
142-
let context_ = context_.with_predicate_iri(unsafe {::linked_data::iref::Iri::new_unchecked(#iri) });
143-
::linked_data::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
142+
let context_ = context_.with_predicate_iri(unsafe {::linked_data_next::iref::Iri::new_unchecked(#iri) });
143+
::linked_data_next::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
144144
vocabulary_,
145145
interpretation_,
146146
dataset_,
@@ -155,12 +155,14 @@ fn generate_field(
155155
None => {
156156
if attrs.is_id || attrs.flatten {
157157
bounds.push(
158-
syn::parse2(quote!(#ty: ::linked_data::LinkedDataDeserializeSubject<I_, V_>))
159-
.unwrap(),
158+
syn::parse2(
159+
quote!(#ty: ::linked_data_next::LinkedDataDeserializeSubject<I_, V_>),
160+
)
161+
.unwrap(),
160162
);
161163

162164
Ok(Some(quote! {
163-
::linked_data::LinkedDataDeserializeSubject::deserialize_subject_in(
165+
::linked_data_next::LinkedDataDeserializeSubject::deserialize_subject_in(
164166
vocabulary_,
165167
interpretation_,
166168
dataset_,

derive/src/generate/de/enum.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ pub fn generate(
3434
VariantShape::Simple(ty) => {
3535
bounds.push(
3636
syn::parse2(
37-
quote!(#ty: ::linked_data::LinkedDataDeserializePredicateObjects<I_, V_>),
37+
quote!(#ty: ::linked_data_next::LinkedDataDeserializePredicateObjects<I_, V_>),
3838
)
3939
.unwrap(),
4040
);
4141

4242
quote! {
43-
match vocabulary_.get(unsafe { ::linked_data::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
43+
match vocabulary_.get(unsafe { ::linked_data_next::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
4444
Some(predicate) => {
4545
let context_ = context_.with_predicate(&predicate);
46-
let result = ::linked_data::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
46+
let result = ::linked_data_next::LinkedDataDeserializePredicateObjects::deserialize_objects_in(
4747
vocabulary_,
4848
interpretation_,
4949
dataset_,
5050
graph_,
51-
::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate),
51+
::linked_data_next::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate),
5252
context_
5353
);
5454

@@ -58,7 +58,7 @@ pub fn generate(
5858
}
5959
}
6060
None => {
61-
error = Some(::linked_data::FromLinkedDataError::MissingRequiredValue(
61+
error = Some(::linked_data_next::FromLinkedDataError::MissingRequiredValue(
6262
context_.into_iris(vocabulary_, interpretation_)
6363
))
6464
}
@@ -74,25 +74,25 @@ pub fn generate(
7474
let constructor = fields_de.constructor;
7575

7676
quote! {
77-
match vocabulary_.get(unsafe { ::linked_data::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
77+
match vocabulary_.get(unsafe { ::linked_data_next::iref::Iri::new_unchecked(#iri) }).and_then(|iri| interpretation_.iri_interpretation(&iri)) {
7878
Some(predicate) => {
79-
let mut objects = ::linked_data::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate);
79+
let mut objects = ::linked_data_next::rdf_types::dataset::PatternMatchingDataset::quad_objects(dataset_, graph_, resource_, &predicate);
8080

8181
let result = match objects.next() {
8282
Some(resource_) => {
8383
(|| {
8484
#(#deserialize_fields)*
8585

8686
if objects.next().is_some() {
87-
Err(::linked_data::FromLinkedDataError::TooManyValues(
87+
Err(::linked_data_next::FromLinkedDataError::TooManyValues(
8888
context_.into_iris(vocabulary_, interpretation_)
8989
))
9090
} else {
9191
Ok(Self::#v_ident #constructor)
9292
}
9393
})()
9494
}
95-
None => Err(::linked_data::FromLinkedDataError::MissingRequiredValue(
95+
None => Err(::linked_data_next::FromLinkedDataError::MissingRequiredValue(
9696
context_.into_iris(vocabulary_, interpretation_)
9797
))
9898
};
@@ -103,7 +103,7 @@ pub fn generate(
103103
}
104104
}
105105
None => {
106-
error = Some(::linked_data::FromLinkedDataError::MissingRequiredValue(
106+
error = Some(::linked_data_next::FromLinkedDataError::MissingRequiredValue(
107107
context_.into_iris(vocabulary_, interpretation_)
108108
))
109109
}
@@ -113,7 +113,7 @@ pub fn generate(
113113
VariantShape::Unit => {
114114
interpretation_bounds.reverse_iri = true;
115115
quote! {
116-
let expected_iri_ = unsafe { ::linked_data::iref::Iri::new_unchecked(#iri) };
116+
let expected_iri_ = unsafe { ::linked_data_next::iref::Iri::new_unchecked(#iri) };
117117
for i in interpretation_.iris_of(resource_) {
118118
let iri_ = vocabulary_.iri(&i).unwrap();
119119
if iri_ == expected_iri_ {
@@ -128,13 +128,13 @@ pub fn generate(
128128
VariantShape::Simple(ty) => {
129129
bounds.push(
130130
syn::parse2(
131-
quote!(#ty: ::linked_data::LinkedDataDeserializeSubject<I_, V_>),
131+
quote!(#ty: ::linked_data_next::LinkedDataDeserializeSubject<I_, V_>),
132132
)
133133
.unwrap(),
134134
);
135135

136136
quote! {
137-
let result = ::linked_data::LinkedDataDeserializeSubject::deserialize_subject_in(
137+
let result = ::linked_data_next::LinkedDataDeserializeSubject::deserialize_subject_in(
138138
vocabulary_,
139139
interpretation_,
140140
dataset_,
@@ -184,25 +184,25 @@ pub fn generate(
184184
let (impl_generics, _, where_clause) = ld_generics.split_for_impl();
185185

186186
Ok(quote! {
187-
impl #impl_generics ::linked_data::LinkedDataDeserializeSubject<I_, V_> for #ident #ty_generics #where_clause {
187+
impl #impl_generics ::linked_data_next::LinkedDataDeserializeSubject<I_, V_> for #ident #ty_generics #where_clause {
188188
fn deserialize_subject_in<D_>(
189189
vocabulary_: &V_,
190190
interpretation_: &I_,
191191
dataset_: &D_,
192192
graph_: Option<&I_::Resource>,
193193
resource_: &I_::Resource,
194-
outer_context_: ::linked_data::Context<I_>
195-
) -> Result<Self, ::linked_data::FromLinkedDataError>
194+
outer_context_: ::linked_data_next::Context<I_>
195+
) -> Result<Self, ::linked_data_next::FromLinkedDataError>
196196
where
197-
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
197+
D_: ::linked_data_next::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
198198
{
199199
let context_ = outer_context_.with_subject(resource_);
200200
let mut error = None;
201201

202202
#(#deserialize_variants)*
203203

204204
Err(error.unwrap_or_else(|| {
205-
::linked_data::FromLinkedDataError::InvalidSubject {
205+
::linked_data_next::FromLinkedDataError::InvalidSubject {
206206
context: outer_context_.into_iris(vocabulary_, interpretation_),
207207
subject: interpretation_.iris_of(resource_).next().map(|i| {
208208
vocabulary_.iri(i).unwrap().to_owned()
@@ -212,24 +212,24 @@ pub fn generate(
212212
}
213213
}
214214

215-
impl #impl_generics ::linked_data::LinkedDataDeserializePredicateObjects<I_, V_> for #ident #ty_generics #where_clause {
215+
impl #impl_generics ::linked_data_next::LinkedDataDeserializePredicateObjects<I_, V_> for #ident #ty_generics #where_clause {
216216
fn deserialize_objects_in<'de_, D_>(
217217
vocabulary: &V_,
218218
interpretation: &I_,
219219
dataset: &D_,
220220
graph: Option<&I_::Resource>,
221221
objects: impl IntoIterator<Item = &'de_ I_::Resource>,
222-
context: ::linked_data::Context<I_>
223-
) -> Result<Self, ::linked_data::FromLinkedDataError>
222+
context: ::linked_data_next::Context<I_>
223+
) -> Result<Self, ::linked_data_next::FromLinkedDataError>
224224
where
225225
I_::Resource: 'de_,
226-
D_: ::linked_data::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
226+
D_: ::linked_data_next::rdf_types::dataset::PatternMatchingDataset<Resource = I_::Resource>
227227
{
228228
let mut objects = objects.into_iter();
229229

230230
match objects.next() {
231231
Some(object) => {
232-
let value = <Self as ::linked_data::LinkedDataDeserializeSubject<I_, V_>>::deserialize_subject_in(
232+
let value = <Self as ::linked_data_next::LinkedDataDeserializeSubject<I_, V_>>::deserialize_subject_in(
233233
vocabulary,
234234
interpretation,
235235
dataset,
@@ -239,15 +239,15 @@ pub fn generate(
239239
)?;
240240

241241
if objects.next().is_some() {
242-
Err(::linked_data::FromLinkedDataError::TooManyValues(
242+
Err(::linked_data_next::FromLinkedDataError::TooManyValues(
243243
context.into_iris(vocabulary, interpretation)
244244
))
245245
} else {
246246
Ok(value)
247247
}
248248
}
249249
None => {
250-
Err(::linked_data::FromLinkedDataError::MissingRequiredValue(
250+
Err(::linked_data_next::FromLinkedDataError::MissingRequiredValue(
251251
context.into_iris(vocabulary, interpretation)
252252
))
253253
}

0 commit comments

Comments
 (0)