Skip to main content

picodata_driver/
lib.rs

1#![allow(clippy::mutable_key_type, clippy::inline_always)]
2
3mod accessor;
4pub(crate) mod bucket;
5mod client;
6mod config;
7mod discovery;
8mod error;
9mod instance;
10mod manager;
11pub(crate) mod metadata;
12mod pool;
13mod strategy;
14mod tls;
15pub(crate) mod topology;
16
17pub use client::*;
18pub use config::*;
19pub use error::*;
20pub use strategy::*;
21pub use topology::view::{BucketMap, Instance, Replicaset, Tier, Topology};
22
23/// Creates a picodata `Client`
24///
25/// # Parameters
26///
27/// - `config`: A string with parameters.
28///
29/// # Errors
30///
31/// - Any [`Error`] than `Client` initializer may return.
32///
33/// # Returns
34///
35/// An instances of `Client` on success or an `Error` if init did fail.
36pub async fn connect(config: &str) -> Result<Client, Error> {
37    let cfg = Config::from(config.parse::<pg::Config>()?);
38    Client::new(cfg).await
39}
40
41/// Creates a picodata `Client`
42///
43/// # Parameters
44///
45/// - `config`: A config.
46///
47/// # Errors
48///
49/// - Any [`Error`] than `Client` initializer may return.
50///
51/// # Returns
52///
53/// An instances of `Client` on success or an `Error` if init did fail.
54pub async fn connect_cfg(cfg: Config) -> Result<Client, Error> {
55    Client::new(cfg).await
56}