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
//! Builder for [`Blob`] objects.
//!
//! A [`BlobBuilder`] is a thin wrapper around [`Blob::new`] that allows
//! incremental construction. It is the simplest of the builders because
//! a blob has only one field: the raw data.
//!
//! # When to use
//!
//! Use the builder when you want to gather data from multiple sources
//! before finalising the blob. For example, if you are reading a file
//! in chunks and want to store the complete content as a blob, you can
//! collect all chunks into a `Vec<u8>` and then call `.with_data(vec)`.
//!
//! If you already have a `Vec<u8>`, you can just call `Blob::new(data)`
//! directly. The builder is not strictly necessary, but it provides a
//! consistent API across all object types.
//!
//! # Example
//!
//! ```rust
//! use libvctrl_core::object::BlobBuilder;
//! use libvctrl_handler::Blob;
//!
//! let blob = BlobBuilder::new()
//! .with_data(b"Hello, world!".to_vec())
//! .build();
//! assert_eq!(blob.data(), b"Hello, world!");
//! ```
use Blob;
/// Builder for [`Blob`] objects.
///
/// Thin wrapper around [`Blob::new`] that allows incremental construction.
///
/// # Example
///
/// ```rust
/// # use libvctrl_core::object::BlobBuilder;
/// let blob = BlobBuilder::new()
/// .with_data(vec![0u8; 10])
/// .build();
/// ```