rudof_lib 0.2.20-rc.1

RDF data shapes implementation in Rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
use crate::{
    RudofConfig,
    api::{
        comparison::builders::ShowSchemaComparisonBuilder,
        conversion::builders::ShowSchemaConversionBuilder,
        core::{
            CoreOperations,
            builders::{ConfigBuilder, ResetAllBuilder, UpdateConfigBuilder, VersionBuilder},
        },
        data::builders::{
            ListEndpointsBuilder, LoadDataBuilder, LoadServiceDescriptionBuilder, ResetDataBuilder,
            ResetServiceDescriptionBuilder, SerializeDataBuilder, SerializeServiceDescriptionBuilder,
            ShowNodeInfoBuilder,
        },
        dctap::builders::{LoadDctapBuilder, ResetDctapBuilder, SerializeDctapBuilder},
        generation::builders::GenerateDataBuilder,
        map_state::builders::{LoadMapStateBuilder, SerializeMapStateBuilder},
        materialize::builders::MaterializeBuilder,
        pgschema::builders::{
            LoadPgSchemaBuilder, LoadTypemapBuilder, PgSchemaValidationBuilder, ResetPgSchemaBuilder,
            ResetPgSchemaValidationBuilder, ResetTypemapBuilder, SerializePgSchemaBuilder,
            SerializePgSchemaValidationResultsBuilder,
        },
        query::builders::{
            LoadQueryBuilder, ResetQueryBuilder, ResetQueryResultsBuilder, RunQueryBuilder, SerializeQueryBuilder,
            SerializeQueryResultsBuilder,
        },
        rdf_config::builders::{LoadRdfConfigBuilder, ResetRdfConfigBuilder, SerializeRdfConfigBuilder},
        shacl::builders::{
            LoadShaclShapesBuilder, ResetShaclBuilder, ResetShaclShapesBuilder, SerializeShaclShapesBuilder,
            SerializeShaclValidationResultsBuilder, ValidateShaclBuilder,
        },
        shex::builders::{
            AddNodeShapeToShapemapBuilder, CheckShexSchemaBuilder, LoadShapemapBuilder, LoadShexSchemaBuilder,
            ResetShapemapBuilder, ResetShexBuilder, ResetShexSchemaBuilder, SerializeShapemapBuilder,
            SerializeShexSchemaBuilder, SerializeShexValidationResultsBuilder, ValidateShexBuilder,
        },
    },
    errors::RudofError,
    formats::{
        ComparisonFormat, ComparisonMode, ConversionFormat, ConversionMode, GenerationSchemaFormat, InputSpec,
        ResultConversionFormat, ResultConversionMode,
    },
    types::{Data, QueryResult},
};
use dctap::DCTap as DCTAP;
use pgschema::{pgs::PropertyGraphSchema, type_map::TypeMap, validation_result::ValidationResult};
use rdf_config::RdfConfigModel;
use rudof_rdf::rdf_core::query::SparqlQuery;
use shacl::ir::IRSchema;
use shacl::validator::report::ValidationReport;
use shex_ast::ir::schema_ir::SchemaIR as ShExSchemaIR;
use shex_ast::shapemap::{QueryShapeMap, ResultShapeMap};
use shex_ast::{Schema as ShExSchema, ir::map_state::MapState};
use shex_validation::Validator as ShExValidator;
use sparql_service::ServiceDescription;
use std::io;

/// Typedef for `Result` returned by Rudof operations, where errors are boxed into `RudofError`.
/// Allows easier error handling across library-specific subsystems.
pub type Result<T> = std::result::Result<T, RudofError>;

/// The central `Rudof` struct acts as the main context and state machine.
///
/// It encapsulates everything needed for operations, holding references to currently loaded data, schemas
/// and processing results.
#[derive(Debug)]
pub struct Rudof {
    /// Version of Rudof
    pub(crate) version: String,

    /// Current configuration
    pub(crate) config: RudofConfig,

    /// Current Data
    pub(crate) data: Option<Data>,

    /// Current SHACL Schema Internal Representation
    pub(crate) shacl_shapes: Option<IRSchema>,

    /// Current SHACL validation results
    pub(crate) shacl_validation_results: Option<ValidationReport>,

    /// Current ShEx Schema
    pub(crate) shex_schema: Option<ShExSchema>,

    /// ShEx Schema Internal Representation
    pub(crate) shex_schema_ir: Option<ShExSchemaIR>,

    /// Current Shape Map
    pub(crate) shapemap: Option<QueryShapeMap>,

    /// Current ShEx validator. It holds the compiled schema and the validator which can be reused several times if needed
    pub(crate) shex_validator: Option<ShExValidator>,

    /// Current ShEx validation results
    pub(crate) shex_validation_results: Option<ResultShapeMap>,

    /// Current PGSchema
    pub(crate) pg_schema: Option<PropertyGraphSchema>,

    /// Current typemap
    pub(crate) typemap: Option<TypeMap>,

    /// Current PGSchema validation results
    pub(crate) pg_schema_validation_results: Option<ValidationResult>,

    /// Current SPARQL Query
    pub(crate) query: Option<SparqlQuery>,

    /// Current query results
    pub(crate) query_results: Option<QueryResult>,

    /// Current DCTAP
    pub(crate) dctap: Option<DCTAP>,

    /// Current Service Description
    pub(crate) service_description: Option<ServiceDescription>,

    /// Current rdf_config model
    pub(crate) rdf_config: Option<RdfConfigModel>,

    /// Current map state for ShEx validation used by Map Semantic Actions and materialize option
    pub(crate) map_state: Option<MapState>,
}

impl Rudof {
    // ========================================================================
    // RudofCore methods
    // ========================================================================

    /// Create a new `Rudof` instance from the provided `RudofConfig`.
    ///
    /// # Parameters
    /// - `config`: `Rudof` configuration settings (`RudofConfig`).
    pub fn new(config: RudofConfig) -> Self {
        <Self as CoreOperations>::new(config)
    }

    /// Returns a `VersionBuilder` for retrieving Rudof's version.
    pub fn version<'a>(&'a self) -> VersionBuilder<'a> {
        VersionBuilder::new(self)
    }

    /// Returns a `ConfigBuilder` that exposes the current `RudofConfig`.
    pub fn config<'a>(&'a self) -> ConfigBuilder<'a> {
        ConfigBuilder::new(self)
    }

    /// Returns an `UpdateConfigBuilder` to replace/update the current config.
    ///
    /// # Parameters
    /// - `config`: new configuration to replace the current one.
    pub fn update_config<'a>(&'a mut self, config: RudofConfig) -> UpdateConfigBuilder<'a> {
        UpdateConfigBuilder::new(self, config)
    }

    /// Returns a `ResetAllBuilder` that resets all runtime state in `Rudof`.
    pub fn reset_all<'a>(&'a mut self) -> ResetAllBuilder<'a> {
        ResetAllBuilder::new(self)
    }

    // ========================================================================
    // DataOperations methods
    // ========================================================================

    /// Returns a `LoadDataBuilder` to load RDF or PG data into `Rudof`'s state.
    pub fn load_data<'a>(&'a mut self) -> LoadDataBuilder<'a> {
        LoadDataBuilder::new(self)
    }

    /// Returns a `SerializeDataBuilder` that writes the currently-loaded data to the given `writer` (any `io::Write`).
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized data (e.g., file, stdout, in-memory buffer).
    pub fn serialize_data<'a, W: io::Write>(&'a mut self, writer: &'a mut W) -> SerializeDataBuilder<'a, W> {
        SerializeDataBuilder::new(self, writer)
    }

    /// Returns a `LoadMapStateBuilder` to load a MapState from a JSON file at `path`.
    ///
    /// # Parameters
    /// - `path`: filesystem path to the JSON-encoded MapState file.
    pub fn load_map_state<'a>(&'a mut self, path: &'a std::path::Path) -> LoadMapStateBuilder<'a> {
        LoadMapStateBuilder::new(self, path)
    }

    pub fn serialize_map_state<'a, W: io::Write>(&'a mut self, writer: &'a mut W) -> SerializeMapStateBuilder<'a, W> {
        SerializeMapStateBuilder::new(self, writer)
    }

    /// Returns a `MaterializeBuilder` to generate an RDF graph from the current
    /// ShEx schema and Map semantic-action state.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized RDF graph.
    pub fn materialize<'a, W: io::Write>(&'a self, writer: &'a mut W) -> MaterializeBuilder<'a, W> {
        MaterializeBuilder::new(self, writer)
    }

    /// Returns a `ResetDataBuilder` to clear loaded data from `Rudof`.
    pub fn reset_data<'a>(&'a mut self) -> ResetDataBuilder<'a> {
        ResetDataBuilder::new(self)
    }

    /// Returns a `LoadServiceDescriptionBuilder` to load a service description described by `service` (`InputSpec`).
    ///
    /// # Parameters
    /// - `service`: input specification for the service description.
    pub fn load_service_description<'a>(&'a mut self, service: &'a InputSpec) -> LoadServiceDescriptionBuilder<'a> {
        LoadServiceDescriptionBuilder::new(self, service)
    }

    /// Returns a `SerializeServiceDescriptionBuilder` to write the currentservice description to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized service description.
    pub fn serialize_service_description<'a, W: io::Write>(
        &'a self,
        writer: &'a mut W,
    ) -> SerializeServiceDescriptionBuilder<'a, W> {
        SerializeServiceDescriptionBuilder::new(self, writer)
    }

    /// Returns a `ResetServiceDescriptionBuilder` to clear any loaded service description from the internal state.
    pub fn reset_service_description<'a>(&'a mut self) -> ResetServiceDescriptionBuilder<'a> {
        ResetServiceDescriptionBuilder::new(self)
    }

    /// Returns a `ShowNodeInfoBuilder` that writes structural inspection information
    /// about the given `node` (within the loaded data) to `writer`.
    ///
    /// # Parameters
    /// - `node`: the IRI or ID of the node to inspect.
    /// - `writer`: output target for the formatted node information.
    pub fn show_node_info<'a, W: io::Write>(
        &'a mut self,
        node: &'a str,
        writer: &'a mut W,
    ) -> ShowNodeInfoBuilder<'a, W> {
        ShowNodeInfoBuilder::new(self, node, writer)
    }

    /// Returns a `ListEndpointsBuilder` that enumerates known endpoints.
    pub fn list_endpoints<'a>(&'a mut self) -> ListEndpointsBuilder<'a> {
        ListEndpointsBuilder::new(self)
    }

    // ========================================================================
    // ShExOperations methods
    // ========================================================================

    /// Returns a `LoadShexSchemaBuilder` to load a ShEx schema from `schema` (`InputSpec`) into the internal state.
    ///
    /// # Parameters
    /// - `schema`: input specification for the ShEx schema to load.
    pub fn load_shex_schema<'a>(&'a mut self, schema: &'a InputSpec) -> LoadShexSchemaBuilder<'a> {
        LoadShexSchemaBuilder::new(self, schema)
    }

    /// Returns a `CheckShexSchemaBuilder` to perform syntactic/semantic checks on a ShEx schema described by `schema` and write results to
    /// `writer`.
    ///
    /// # Parameters
    /// - `schema`: input specification for the ShEx schema to check.
    /// - `writer`: output target for the check results.
    pub fn check_shex_schema<'a, W: io::Write>(
        &'a self,
        schema: &'a InputSpec,
        writer: &'a mut W,
    ) -> CheckShexSchemaBuilder<'a, W> {
        CheckShexSchemaBuilder::new(self, schema, writer)
    }

    /// Returns a `SerializeShexSchemaBuilder` that writes the currently loaded ShEx schema to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized ShEx schema.
    pub fn serialize_shex_schema<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeShexSchemaBuilder<'a, W> {
        SerializeShexSchemaBuilder::new(self, writer)
    }

    /// Returns a `ResetShexSchemaBuilder` to clear the currently-loaded ShEx schema from state.
    pub fn reset_shex_schema<'a>(&'a mut self) -> ResetShexSchemaBuilder<'a> {
        ResetShexSchemaBuilder::new(self)
    }

    /// Returns a `LoadShapemapBuilder` to load a ShEx shapemap from `shapemap` (`InputSpec`).
    ///
    /// # Parameters
    /// - `shapemap`: input specification for the ShEx shapemap to load.
    pub fn load_shapemap<'a>(&'a mut self, shapemap: &'a InputSpec) -> LoadShapemapBuilder<'a> {
        LoadShapemapBuilder::new(self, shapemap)
    }

    /// Returns an `AddNodeShapeToShapemapBuilder` to add a node/shape association to the shapemap.
    ///
    /// Creates the shapemap if none is currently loaded.
    ///
    /// # Parameters
    /// - `node`: node selector string (e.g. `<http://example.org/node>`).
    pub fn add_node_shape_to_shapemap<'a>(&'a mut self, node: &'a str) -> AddNodeShapeToShapemapBuilder<'a> {
        AddNodeShapeToShapemapBuilder::new(self, node)
    }

    /// Returns a `SerializeShapemapBuilder` that writes the current shapemap to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized shapemap.
    pub fn serialize_shapemap<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeShapemapBuilder<'a, W> {
        SerializeShapemapBuilder::new(self, writer)
    }

    /// Returns a `ResetShapemapBuilder` to clear the stored shapemap.
    pub fn reset_shapemap<'a>(&'a mut self) -> ResetShapemapBuilder<'a> {
        ResetShapemapBuilder::new(self)
    }

    /// Returns a `ValidateShexBuilder` to run ShEx validation using the currently-loaded schema, shapemap and data.
    pub fn validate_shex<'a>(&'a mut self) -> ValidateShexBuilder<'a> {
        ValidateShexBuilder::new(self)
    }

    /// Returns a `SerializeShexValidationResultsBuilder` to write ShEx validation results to `writer`.
    pub fn serialize_shex_validation_results<'a, W: io::Write>(
        &'a self,
        writer: &'a mut W,
    ) -> SerializeShexValidationResultsBuilder<'a, W> {
        SerializeShexValidationResultsBuilder::new(self, writer)
    }

    /// Returns a `ResetShexBuilder` to clear ShEx validation state and results.
    pub fn reset_shex<'a>(&'a mut self) -> ResetShexBuilder<'a> {
        ResetShexBuilder::new(self)
    }

    // ========================================================================
    // ShaclOperations methods
    // ========================================================================

    /// Returns a `LoadShaclShapesBuilder` to load SHACL shapes into the internal state.
    pub fn load_shacl_shapes<'a>(&'a mut self) -> LoadShaclShapesBuilder<'a> {
        LoadShaclShapesBuilder::new(self)
    }

    /// Returns a `SerializeShaclShapesBuilder` that writes loaded SHACL shapes to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized SHACL shapes.
    pub fn serialize_shacl_shapes<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeShaclShapesBuilder<'a, W> {
        SerializeShaclShapesBuilder::new(self, writer)
    }

    /// Returns a `ResetShaclShapesBuilder` to clear loaded SHACL shapes.
    pub fn reset_shacl_shapes<'a>(&'a mut self) -> ResetShaclShapesBuilder<'a> {
        ResetShaclShapesBuilder::new(self)
    }

    /// Returns a `ValidateShaclBuilder` to perform SHACL validation on the
    /// currently-loaded shapes and data.
    pub fn validate_shacl<'a>(&'a mut self) -> ValidateShaclBuilder<'a> {
        ValidateShaclBuilder::new(self)
    }

    /// Returns a `SerializeShaclValidationResultsBuilder` to write SHACL
    /// validation results to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized SHACL validation results.
    pub fn serialize_shacl_validation_results<'a, W: io::Write>(
        &'a self,
        writer: &'a mut W,
    ) -> SerializeShaclValidationResultsBuilder<'a, W> {
        SerializeShaclValidationResultsBuilder::new(self, writer)
    }

    /// Returns a `ResetShaclBuilder` to clear SHACL validation
    /// results from the internal state.
    pub fn reset_shacl<'a>(&'a mut self) -> ResetShaclBuilder<'a> {
        ResetShaclBuilder::new(self)
    }

    // ========================================================================
    // QueryOperations methods
    // ========================================================================

    /// Returns a `LoadQueryBuilder` to load a SPARQL query into state from
    /// `query` (`InputSpec`).
    ///
    /// # Parameters
    /// - `query`: input specification for the SPARQL query to load.
    pub fn load_query<'a>(&'a mut self, query: &'a InputSpec) -> LoadQueryBuilder<'a> {
        LoadQueryBuilder::new(self, query)
    }

    /// Returns a `SerializeQueryBuilder` that writes the currently-loaded
    /// query to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized SPARQL query.
    pub fn serialize_query<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeQueryBuilder<'a, W> {
        SerializeQueryBuilder::new(self, writer)
    }

    /// Returns a `ResetQueryBuilder` to clear the stored query.
    pub fn reset_query<'a>(&'a mut self) -> ResetQueryBuilder<'a> {
        ResetQueryBuilder::new(self)
    }

    /// Returns a `RunQueryBuilder` to execute the currently-loaded SPARQL
    /// query against the loaded data.
    pub fn run_query<'a>(&'a mut self) -> RunQueryBuilder<'a> {
        RunQueryBuilder::new(self)
    }

    /// Returns a `SerializeQueryResultsBuilder` that writes query results
    /// to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized query results.
    pub fn serialize_query_results<'a, W: io::Write>(
        &'a self,
        writer: &'a mut W,
    ) -> SerializeQueryResultsBuilder<'a, W> {
        SerializeQueryResultsBuilder::new(self, writer)
    }

    /// Returns a `ResetQueryResultsBuilder` to clear stored query results.
    pub fn reset_query_results<'a>(&'a mut self) -> ResetQueryResultsBuilder<'a> {
        ResetQueryResultsBuilder::new(self)
    }

    // ========================================================================
    // ComparisonOperations methods
    // ========================================================================

    /// Returns a `ShowSchemaComparisonBuilder` to compare two schemas.
    ///
    /// - `schema1`/`schema2`: input specifications for both schemas.
    /// - `format1`/`format2`: formats for the inputs.
    /// - `mode1`/`mode2`: types for the comparison.
    /// - `writer`: output target for the comparison report.
    pub fn show_schema_comparison<'a, W: io::Write>(
        &'a mut self,
        schema1: &'a InputSpec,
        schema2: &'a InputSpec,
        format1: &'a ComparisonFormat,
        format2: &'a ComparisonFormat,
        mode1: &'a ComparisonMode,
        mode2: &'a ComparisonMode,
        writer: &'a mut W,
    ) -> ShowSchemaComparisonBuilder<'a, W> {
        ShowSchemaComparisonBuilder::new(self, schema1, schema2, format1, format2, mode1, mode2, writer)
    }

    // ========================================================================
    // ConversionOperations methods
    // ========================================================================

    /// Returns a `ShowSchemaConversionBuilder` to convert a schema between
    /// formats or representations.
    ///
    /// - `schema`: input specification
    /// - `input_mode`/`output_mode`: types for the conversion
    /// - `input_format`/`output_format`: concrete format choices
    /// - `writer`: output target for the converted schema/result
    pub fn show_schema_conversion<'a, W: io::Write>(
        &'a mut self,
        schema: &'a InputSpec,
        input_mode: &'a ConversionMode,
        output_mode: &'a ResultConversionMode,
        input_format: &'a ConversionFormat,
        output_format: &'a ResultConversionFormat,
        writer: &'a mut W,
    ) -> ShowSchemaConversionBuilder<'a, W> {
        ShowSchemaConversionBuilder::new(
            self,
            schema,
            input_mode,
            output_mode,
            input_format,
            output_format,
            writer,
        )
    }

    // ========================================================================
    // DctapOperations methods
    // ========================================================================

    /// Returns a `LoadDctapBuilder` to load a DCTAP model from `dctap`.
    ///
    /// # Parameters
    /// - `dctap`: input specification for the DCTAP model to load.
    pub fn load_dctap<'a>(&'a mut self, dctap: &'a InputSpec) -> LoadDctapBuilder<'a> {
        LoadDctapBuilder::new(self, dctap)
    }

    /// Returns a `SerializeDctapBuilder` that writes the loaded DCTAP
    /// model to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized DCTAP model.
    pub fn serialize_dctap<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeDctapBuilder<'a, W> {
        SerializeDctapBuilder::new(self, writer)
    }

    /// Returns a `ResetDctapBuilder` to clear loaded DCTAP from state.
    pub fn reset_dctap<'a>(&'a mut self) -> ResetDctapBuilder<'a> {
        ResetDctapBuilder::new(self)
    }

    // ========================================================================
    // RdfConfigOperations methods
    // ========================================================================

    /// Returns a `LoadRdfConfigBuilder` to load RDF configuration from
    /// `rdf_config` (`InputSpec`).
    pub fn load_rdf_config<'a>(&'a mut self, rdf_config: &'a InputSpec) -> LoadRdfConfigBuilder<'a> {
        LoadRdfConfigBuilder::new(self, rdf_config)
    }

    /// Returns a `SerializeRdfConfigBuilder` that writes the loaded RDF
    /// configuration to `writer`.
    pub fn serialize_rdf_config<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializeRdfConfigBuilder<'a, W> {
        SerializeRdfConfigBuilder::new(self, writer)
    }

    /// Returns a `ResetRdfConfigBuilder` to clear the loaded RDF
    /// configuration.
    pub fn reset_rdf_config<'a>(&'a mut self) -> ResetRdfConfigBuilder<'a> {
        ResetRdfConfigBuilder::new(self)
    }

    // ========================================================================
    // PgSchemaOperations methods
    // ========================================================================

    /// Returns a `LoadPgSchemaBuilder` to load a PGSchema from `pg_schema`.
    ///
    /// # Parameters
    /// - `pg_schema`: input specification for the PGSchema to load.
    pub fn load_pg_schema<'a>(&'a mut self, pg_schema: &'a InputSpec) -> LoadPgSchemaBuilder<'a> {
        LoadPgSchemaBuilder::new(self, pg_schema)
    }

    /// Returns a `SerializePgSchemaBuilder` that writes the loaded
    /// PGSchema to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized PGSchema.
    pub fn serialize_pg_schema<'a, W: io::Write>(&'a self, writer: &'a mut W) -> SerializePgSchemaBuilder<'a, W> {
        SerializePgSchemaBuilder::new(self, writer)
    }

    /// Returns a `ResetPgSchemaBuilder` to clear the loaded PGSchema.
    pub fn reset_pg_schema<'a>(&'a mut self) -> ResetPgSchemaBuilder<'a> {
        ResetPgSchemaBuilder::new(self)
    }

    /// Returns a `LoadTypemapBuilder` to load a typemap into state.
    ///
    /// # Parameters
    /// - `typemap`: input specification for the typemap to load.
    pub fn load_typemap<'a>(&'a mut self, typemap: &'a InputSpec) -> LoadTypemapBuilder<'a> {
        LoadTypemapBuilder::new(self, typemap)
    }

    /// Returns a `ResetTypemapBuilder` to clear the typemap.
    pub fn reset_typemap<'a>(&'a mut self) -> ResetTypemapBuilder<'a> {
        ResetTypemapBuilder::new(self)
    }

    /// Returns a `PgSchemaValidationBuilder` to validate the currently
    /// loaded PGSchema and typemap.
    pub fn validate_pgschema<'a>(&'a mut self) -> PgSchemaValidationBuilder<'a> {
        PgSchemaValidationBuilder::new(self)
    }

    /// Returns a `SerializePgSchemaValidationResultsBuilder` to write PG
    /// schema validation results to `writer`.
    ///
    /// # Parameters
    /// - `writer`: output target for the serialized PGSchema validation results.
    pub fn serialize_pgschema_validation_results<'a, W: io::Write>(
        &'a self,
        writer: &'a mut W,
    ) -> SerializePgSchemaValidationResultsBuilder<'a, W> {
        SerializePgSchemaValidationResultsBuilder::new(self, writer)
    }

    /// Returns a `ResetPgSchemaValidationBuilder` to clear PGSchema
    /// validation results.
    pub fn reset_pg_schema_validation<'a>(&'a mut self) -> ResetPgSchemaValidationBuilder<'a> {
        ResetPgSchemaValidationBuilder::new(self)
    }

    // ========================================================================
    // GenerationOperations methods
    // ========================================================================

    /// Returns a `GenerateDataBuilder` to synthesize mock data based on the provided schema.
    ///
    /// # Parameters
    /// - `schema`: input specification for the schema (e.g., ShEx file)
    /// - `schema_format`: format of the provided schema
    /// - `number_entities`: approximate number of target entities to generate
    pub fn generate_data<'a>(
        &'a self,
        schema: &'a InputSpec,
        schema_format: &'a GenerationSchemaFormat,
        number_entities: usize,
    ) -> GenerateDataBuilder<'a> {
        GenerateDataBuilder::new(self, schema, schema_format, number_entities)
    }
}