Skip to main content

svix/
lib.rs

1// SPDX-FileCopyrightText: © 2022 Svix Authors
2// SPDX-License-Identifier: MIT
3
4//! Rust client library for Svix.
5//!
6//! The main entry points of this library are the API client [`api::Svix`], and
7//! [`webhooks::Webhook`].
8
9#![forbid(unsafe_code)]
10
11use std::time::Duration;
12
13use hyper::body::Bytes;
14use hyper_util::client::legacy::Client as HyperClient;
15
16pub mod api;
17mod connector;
18pub mod error;
19mod model_ext;
20mod models;
21mod request;
22pub mod webhooks;
23
24pub(crate) use connector::{make_connector, Connector};
25
26pub struct Configuration {
27    pub base_path: String,
28    pub user_agent: Option<String>,
29    pub bearer_access_token: Option<String>,
30    pub timeout: Option<Duration>,
31    pub num_retries: u32,
32    pub retry_schedule: Option<Vec<Duration>>,
33
34    client: HyperClient<Connector, http_body_util::Full<Bytes>>,
35}
36
37/// Convert a `StatusCode` from the http crate v1 to one from the http crate
38/// v0.2.
39fn http1_to_02_status_code(code: http1::StatusCode) -> http02::StatusCode {
40    http02::StatusCode::from_u16(code.as_u16())
41        .expect("both versions of the http crate enforce the same numerical limits for StatusCode")
42}