couchbase 1.0.1

The official Couchbase Rust SDK
Documentation
/*
 *
 *  * Copyright (c) 2025 Couchbase, Inc.
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  *    http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */
use crate::common::node_version::{NodeEdition, NodeVersion};
use couchbase::error::Error;
use std::ops::Add;
use std::time::Duration;
use tokio::time::{timeout_at, Instant};

pub async fn run_with_std_kv_deadline<Resp, Fut>(
    node_version: &NodeVersion,
    f: Fut,
) -> Result<Resp, Error>
where
    Fut: std::future::Future<Output = Result<Resp, Error>>,
{
    let timeout = match node_version.edition {
        Some(NodeEdition::Community) => Duration::from_millis(10000),
        _ => Duration::from_millis(2500),
    };

    timeout_at(Instant::now().add(timeout), f).await.unwrap()
}