picodata-driver 3.0.0

A native asyncronous cluster-aware Picodata client
Documentation
use std::io;

/// Details of [`Error::IncompleteBucketMap`].
#[derive(Debug)]
#[non_exhaustive]
pub struct IncompleteBucketMap {
    /// Tier whose bucket map is incomplete.
    pub tier: String,
    /// Number of buckets actually covered by the map.
    pub covered: u64,
    /// Number of buckets the tier is configured with.
    pub expected: u64,
}

/// Picodata error.
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
    /// Manager has been closed, no further operations allowed.
    #[error("manager has been closed")]
    Closed,
    /// No online instances available to handle the request.
    #[error("no online instances available")]
    Unreachable,
    /// The instance a query was pinned to is unknown or offline.
    #[error("instance {0} is not available")]
    InstanceUnavailable(String),
    /// A tier's buckets are not fully covered by the topology.
    #[error(
        "bucket map for tier {} covers {} of {} buckets",
        .0.tier, .0.covered, .0.expected
    )]
    IncompleteBucketMap(Box<IncompleteBucketMap>),
    /// Address could not be parsed from returned row.
    #[error("instance address is invalid: {0}")]
    InvalidAddress(String),
    /// Port could not be parsed from returned row.
    #[error("instance port is invalid")]
    InvalidPort,
    /// A UUID could not be parsed from returned row.
    #[error("uuid is invalid: {0}")]
    InvalidUuid(#[from] uuid::Error),
    /// Any error happened within tokio postgres.
    #[error("postgres protocol error: {0}")]
    Postgres(#[from] pg::Error),
    /// Any error happended within deadpool.
    #[error("postgres pool error: {0}")]
    PostgresPool(#[from] pgpool::PoolError),
    /// Any error happened on I/O.
    #[error("io error: {0}")]
    IO(#[from] io::Error),
}