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
/*
* @Author: Jerry.Yang
* @Date: 2024-10-17 15:07:52
* @LastEditors: Jerry.Yang
* @LastEditTime: 2025-02-05 14:18:01
* @Description: Defines the `Client` and its builder `ClientBuilder` to encapsulate client configuration,
* client information, and request handlers for interacting with the Volcengine API.
*/
use client_info;
use crateconfig;
use crateerror;
use cratehandles;
// `Client` struct that holds the client information, configuration, and request handler.
//
// This struct is the main client object used to interact with Volcengine services. It contains all the
// necessary data to authenticate, configure, and send requests to the Volcengine API.
//
// # Fields:
// - `client_info`: Holds the client information such as identification details, credentials, etc.
// - `config`: Contains the configuration data that defines the client's behavior and connection settings.
// - `handles`: Manages the request handlers responsible for handling communication with the API.
// `Client` implementation providing a `builder` function for constructing `ClientBuilder`
// The `builder` method allows for a more flexible and readable way to construct a `Client` by chaining method calls
// `ClientBuilder` struct to incrementally build a `Client` object.
//
// The `ClientBuilder` struct provides a builder pattern to facilitate the creation of a `Client` object.
// Each method allows setting a specific field of the `Client` and returns the builder for method chaining.
//
// # Fields:
// - `client_info`: Optional client information for the API client, may be set using `with_client_info`.
// - `config`: Optional configuration for the client, set via `with_config`.
// - `handles`: Optional request handler, set using `with_handles`.
// `ClientBuilder` implementation to add fields to the `Client` struct and build it with validation.
//
// The `ClientBuilder` provides methods for setting each field of the `Client`. These methods are chainable,
// allowing for a fluent API. The `build` method performs validation to ensure all required fields are set before
// returning the final `Client` instance.
//
// # Methods:
// - `with_client_info`: Sets the `client_info` field in the builder.
// - `with_config`: Sets the `config` field in the builder.
// - `with_handles`: Sets the `handles` field in the builder.
// - `build`: Finalizes the builder, ensuring that all required fields are set, and returns the constructed `Client` instance.