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
use crate::{
Result, Rudof,
api::shex::ShExOperations,
formats::{DataReaderMode, InputSpec, ShExFormat},
};
/// Builder for `load_shex_schema` operation.
///
/// Provides a fluent interface for configuring and executing schema loading
/// operations with optional parameters.
pub struct LoadShexSchemaBuilder<'a> {
rudof: &'a mut Rudof,
schema: &'a InputSpec,
schema_format: Option<&'a ShExFormat>,
base_schema: Option<&'a str>,
reader_mode: Option<&'a DataReaderMode>,
}
impl<'a> LoadShexSchemaBuilder<'a> {
/// Creates a new builder instance.
///
/// This is called internally by `Rudof::load_shex_schema()` and should not
/// be constructed directly.
pub(crate) fn new(rudof: &'a mut Rudof, schema: &'a InputSpec) -> Self {
Self {
rudof,
schema,
schema_format: None,
base_schema: None,
reader_mode: None,
}
}
/// Sets the ShEx schema format.
///
/// # Arguments
///
/// * `schema_format` - The format to use when loading the schema
pub fn with_shex_schema_format(mut self, schema_format: &'a ShExFormat) -> Self {
self.schema_format = Some(schema_format);
self
}
/// Sets the base IRI for resolving relative IRIs in the schema.
///
/// # Arguments
///
/// * `base_schema` - The base IRI to use for resolution
pub fn with_base(mut self, base_schema: &'a str) -> Self {
self.base_schema = Some(base_schema);
self
}
/// Sets the reader mode for schema loading.
///
/// # Arguments
///
/// * `reader_mode` - The reading mode to apply during schema loading
pub fn with_reader_mode(mut self, reader_mode: &'a DataReaderMode) -> Self {
self.reader_mode = Some(reader_mode);
self
}
/// Executes the schema loading operation with the configured parameters.
pub fn execute(self) -> Result<()> {
<Rudof as ShExOperations>::load_shex_schema(
self.rudof,
self.schema,
self.schema_format,
self.base_schema,
self.reader_mode,
)
}
}