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
use crate::{Result, Rudof, api::shex::ShExOperations, formats::ShExFormat};
use std::io;
/// Builder for `serialize_shex_schema` operation.
///
/// Provides a fluent interface for configuring and executing schema serialization
/// operations with optional parameters.
pub struct SerializeShexSchemaBuilder<'a, W: io::Write> {
rudof: &'a Rudof,
writer: &'a mut W,
shape_label: Option<&'a str>,
show_schema: Option<bool>,
show_statistics: Option<bool>,
show_dependencies: Option<bool>,
show_time: Option<bool>,
show_colors: Option<bool>,
shex_format: Option<&'a ShExFormat>,
}
impl<'a, W: io::Write> SerializeShexSchemaBuilder<'a, W> {
/// Creates a new builder instance.
///
/// This is called internally by `Rudof::serialize_shex_schema()` and should not
/// be constructed directly.
pub(crate) fn new(rudof: &'a Rudof, writer: &'a mut W) -> Self {
Self {
rudof,
writer,
shape_label: None,
show_schema: None,
show_statistics: None,
show_dependencies: None,
show_time: None,
show_colors: None,
shex_format: None,
}
}
/// Sets a specific shape label to serialize.
///
/// # Arguments
///
/// * `shape_label` - The shape label to serialize (serializes entire schema if None)
pub fn with_shape(mut self, shape_label: &'a str) -> Self {
self.shape_label = Some(shape_label);
self
}
/// Sets whether to include the schema in the output.
///
/// # Arguments
///
/// * `show_schema` - Whether to include the schema (true by default)
pub fn with_show_schema(mut self, show_schema: bool) -> Self {
self.show_schema = Some(show_schema);
self
}
/// Sets whether to include statistics in the output.
///
/// # Arguments
///
/// * `show_statistics` - Whether to include statistics (false by default)
pub fn with_show_statistics(mut self, show_statistics: bool) -> Self {
self.show_statistics = Some(show_statistics);
self
}
/// Sets whether to show shape dependencies.
///
/// # Arguments
///
/// * `show_dependencies` - Whether to show dependencies (false by default)
pub fn with_show_dependencies(mut self, show_dependencies: bool) -> Self {
self.show_dependencies = Some(show_dependencies);
self
}
/// Sets whether to include timing information.
///
/// # Arguments
///
/// * `show_time` - Whether to include timing information (false by default)
pub fn with_show_time(mut self, show_time: bool) -> Self {
self.show_time = Some(show_time);
self
}
/// Sets the format for the result schema.
///
/// # Arguments
///
/// * `shex_format` - The format to serialize the result schema
pub fn with_result_shex_format(mut self, shex_format: &'a ShExFormat) -> Self {
self.shex_format = Some(shex_format);
self
}
/// Executes the schema serialization operation with the configured parameters.
pub fn execute(self) -> Result<()> {
<Rudof as ShExOperations>::serialize_shex_schema(
self.rudof,
self.shape_label,
self.show_schema,
self.show_statistics,
self.show_dependencies,
self.show_time,
self.show_colors,
self.shex_format,
self.writer,
)
}
}