percas_client/
lib.rs

1// Copyright 2025 ScopeDB <contact@scopedb.io>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! A client library for interacting with a Percas cluster.
16
17#![deny(missing_docs)]
18
19mod client;
20mod route;
21
22pub use self::client::Client;
23pub use self::client::ClientBuilder;
24
25pub mod protos;
26
27/// Errors that can occur when using the client.
28#[derive(Debug)]
29pub enum Error {
30    /// The server responded with a "429 Too Many Requests" status code.
31    TooManyRequests,
32    /// An opaque error message from the server.
33    Opaque(String),
34}
35
36impl std::fmt::Display for Error {
37    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38        match self {
39            Error::TooManyRequests => write!(f, "Too many requests"),
40            Error::Opaque(msg) => write!(f, "{msg}"),
41        }
42    }
43}
44
45impl std::error::Error for Error {}