• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //! Client configure module.
15 
16 use crate::util::{Redirect, Retry, Timeout};
17 
18 /// Options and flags which can be used to configure a client.
19 pub(crate) struct ClientConfig {
20     pub(crate) redirect: Redirect,
21     pub(crate) retry: Retry,
22     pub(crate) connect_timeout: Timeout,
23     pub(crate) request_timeout: Timeout,
24     pub(crate) total_timeout: Timeout,
25 }
26 
27 impl ClientConfig {
28     /// Creates a new and default `ClientConfig`.
new() -> Self29     pub(crate) fn new() -> Self {
30         Self {
31             redirect: Redirect::no_limit(),
32             retry: Retry::none(),
33             connect_timeout: Timeout::none(),
34             request_timeout: Timeout::none(),
35             total_timeout: Timeout::none(),
36         }
37     }
38 }
39 
40 impl Default for ClientConfig {
default() -> Self41     fn default() -> Self {
42         Self::new()
43     }
44 }
45