picodata-driver 3.0.0

A native asyncronous cluster-aware Picodata client
Documentation
#![allow(clippy::mutable_key_type, clippy::inline_always)]

mod accessor;
pub(crate) mod bucket;
mod client;
mod config;
mod discovery;
mod error;
mod instance;
mod manager;
pub(crate) mod metadata;
mod pool;
mod strategy;
mod tls;
pub(crate) mod topology;

pub use client::*;
pub use config::*;
pub use error::*;
pub use strategy::*;
pub use topology::view::{BucketMap, Instance, Replicaset, Tier, Topology};

/// Creates a picodata `Client`
///
/// # Parameters
///
/// - `config`: A string with parameters.
///
/// # Errors
///
/// - Any [`Error`] than `Client` initializer may return.
///
/// # Returns
///
/// An instances of `Client` on success or an `Error` if init did fail.
pub async fn connect(config: &str) -> Result<Client, Error> {
    let cfg = Config::from(config.parse::<pg::Config>()?);
    Client::new(cfg).await
}

/// Creates a picodata `Client`
///
/// # Parameters
///
/// - `config`: A config.
///
/// # Errors
///
/// - Any [`Error`] than `Client` initializer may return.
///
/// # Returns
///
/// An instances of `Client` on success or an `Error` if init did fail.
pub async fn connect_cfg(cfg: Config) -> Result<Client, Error> {
    Client::new(cfg).await
}