Skip to main content

couchbase_core/options/
ping.rs

1/*
2 *
3 *  * Copyright (c) 2025 Couchbase, Inc.
4 *  *
5 *  * Licensed under the Apache License, Version 2.0 (the "License");
6 *  * you may not use this file except in compliance with the License.
7 *  * You may obtain a copy of the License at
8 *  *
9 *  *    http://www.apache.org/licenses/LICENSE-2.0
10 *  *
11 *  * Unless required by applicable law or agreed to in writing, software
12 *  * distributed under the License is distributed on an "AS IS" BASIS,
13 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  * See the License for the specific language governing permissions and
15 *  * limitations under the License.
16 *
17 */
18
19use crate::httpx::request::OnBehalfOfInfo;
20use crate::service_type::ServiceType;
21use std::fmt::Display;
22
23#[derive(Debug, Default, Clone)]
24#[non_exhaustive]
25pub struct PingOptions {
26    pub service_types: Option<Vec<ServiceType>>,
27
28    pub kv_timeout: Option<std::time::Duration>,
29    pub query_timeout: Option<std::time::Duration>,
30    pub search_timeout: Option<std::time::Duration>,
31
32    pub on_behalf_of: Option<OnBehalfOfInfo>,
33}
34
35impl PingOptions {
36    pub fn new() -> Self {
37        Self::default()
38    }
39
40    pub fn service_types(mut self, service_types: Vec<ServiceType>) -> Self {
41        self.service_types = Some(service_types);
42        self
43    }
44
45    pub fn kv_timeout(mut self, timeout: std::time::Duration) -> Self {
46        self.kv_timeout = Some(timeout);
47        self
48    }
49
50    pub fn query_timeout(mut self, timeout: std::time::Duration) -> Self {
51        self.query_timeout = Some(timeout);
52        self
53    }
54
55    pub fn search_timeout(mut self, timeout: std::time::Duration) -> Self {
56        self.search_timeout = Some(timeout);
57        self
58    }
59
60    pub fn on_behalf_of(mut self, info: Option<OnBehalfOfInfo>) -> Self {
61        self.on_behalf_of = info;
62        self
63    }
64}