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
use crate::{Result, Rudof, api::shex::ShExOperations, formats::ShapeMapFormat};
use std::io;
/// Builder for `serialize_shapemap` operation.
///
/// Provides a fluent interface for configuring and executing shape map serialization
/// operations with optional parameters.
pub struct SerializeShapemapBuilder<'a, W: io::Write> {
rudof: &'a Rudof,
show_colors: Option<bool>,
writer: &'a mut W,
shapemap_format: Option<&'a ShapeMapFormat>,
}
impl<'a, W: io::Write> SerializeShapemapBuilder<'a, W> {
/// Creates a new builder instance.
///
/// This is called internally by `Rudof::serialize_shapemap()` and should not
/// be constructed directly.
pub(crate) fn new(rudof: &'a Rudof, writer: &'a mut W) -> Self {
Self {
rudof,
writer,
shapemap_format: None,
show_colors: None,
}
}
/// Sets the output format for shape map serialization.
///
/// # Arguments
///
/// * `shapemap_format` - The format to use when serializing the shape map
pub fn with_result_shapemap_format(mut self, shapemap_format: &'a ShapeMapFormat) -> Self {
self.shapemap_format = Some(shapemap_format);
self
}
/// Sets whether to use colors in the output.
///
/// # Arguments
///
/// * `show_colors` - Whether to use colors in the output
pub fn with_show_colors(mut self, show_colors: bool) -> Self {
self.show_colors = Some(show_colors);
self
}
/// Executes the shape map serialization operation with the configured parameters.
pub fn execute(self) -> Result<()> {
<Rudof as ShExOperations>::serialize_shapemap(self.rudof, self.shapemap_format, self.show_colors, self.writer)
}
}