postgresql_archive/lib.rs
1//! # postgresql_archive
2//!
3//! [](https://codecov.io/gh/theseus-rs/postgresql-embedded)
4//! [](https://bencher.dev/perf/theseus-rs-postgresql-embedded)
5//! [](https://github.com/theseus-rs/postgresql-embedded/tree/main/postgresql_archive#license)
6//! [](https://semver.org/spec/v2.0.0.html)
7//!
8//! Retrieve and extract PostgreSQL on Linux, MacOS or Windows.
9//!
10//! ## Table of contents
11//!
12//! - [Examples](#examples)
13//! - [Feature flags](#feature-flags)
14//! - [Supported platforms](#supported-platforms)
15//! - [Safety](#safety)
16//! - [License](#license)
17//! - [Notes](#notes)
18//!
19//! ## Examples
20//!
21//! ### Asynchronous API
22//!
23//! ```no_run
24//! use postgresql_archive::{extract, get_archive, Result, VersionReq };
25//! use postgresql_archive::configuration::theseus;
26//!
27//! #[tokio::main]
28//! async fn main() -> Result<()> {
29//! let url = theseus::URL;
30//! let (archive_version, archive) = get_archive(url, &VersionReq::STAR).await?;
31//! let out_dir = std::env::temp_dir();
32//! let files = extract(url, &archive, &out_dir).await?;
33//! Ok(())
34//! }
35//! ```
36//!
37//! ### Synchronous API
38//! ```no_run
39//! #[cfg(feature = "blocking")] {
40//! use postgresql_archive::configuration::theseus;
41//! use postgresql_archive::VersionReq;
42//! use postgresql_archive::blocking::{extract, get_archive};
43//!
44//! let url = theseus::URL;
45//! let (archive_version, archive) = get_archive(url, &VersionReq::STAR).unwrap();
46//! let out_dir = std::env::temp_dir();
47//! let result = extract(url, &archive, &out_dir).unwrap();
48//! }
49//! ```
50//!
51//! ## Feature flags
52//!
53//! postgresql_archive uses [feature flags] to address compile time and binary size
54//! uses.
55//!
56//! The following features are available:
57//!
58//! | Name | Description | Default? |
59//! |--------------|----------------------------|----------|
60//! | `blocking` | Enables the blocking API | No |
61//! | `native-tls` | Enables native-tls support | Yes |
62//! | `rustls` | Enables rustls support | No |
63//!
64//! ### Configurations
65//!
66//! | Name | Description | Default? |
67//! |-----------|-------------------------------------|----------|
68//! | `theseus` | Enables theseus PostgreSQL binaries | Yes |
69//! | `zonky` | Enables zonky PostgreSQL binaries | No |
70//!
71//! ### Extractors
72//!
73//! | Name | Description | Default? |
74//! |----------|----------------------|----------|
75//! | `tar-gz` | Enables md5 hashers | Yes |
76//! | `tar-xz` | Enables sha1 hashers | No |
77//! | `zip` | Enables sha2 hashers | No |
78//!
79//! ### Hashers
80//!
81//! | Name | Description | Default? |
82//! |--------|----------------------|----------|
83//! | `md5` | Enables md5 hashers | No |
84//! | `sha1` | Enables sha1 hashers | No |
85//! | `sha2` | Enables sha2 hashers | Yes¹ |
86//!
87//! ¹ enabled by the `theseus` feature flag.
88//!
89//! ### Repositories
90//!
91//! | Name | Description | Default? |
92//! |----------|---------------------------|----------|
93//! | `github` | Enables github repository | Yes¹ |
94//! | `maven` | Enables maven repository | No |
95//!
96//! ¹ enabled by the `theseus` feature flag.
97//!
98//! ## Supported platforms
99//!
100//! `postgresql_archive` provides implementations for the following:
101//!
102//! * [theseus-rs/postgresql-binaries](https://github.com/theseus-rs/postgresql-binaries)
103//! * [zonkyio/embedded-postgres-binaries](https://github.com/zonkyio/embedded-postgres-binaries)
104//!
105//! ## Safety
106//!
107//! This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.
108//!
109//! ## License
110//!
111//! Licensed under either of
112//!
113//! * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
114//! * MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/licenses/MIT>)
115//!
116//! at your option.
117//!
118//! PostgreSQL is covered under [The PostgreSQL License](https://opensource.org/licenses/postgresql).
119
120#![forbid(unsafe_code)]
121#![forbid(clippy::allow_attributes)]
122#![deny(clippy::pedantic)]
123#![allow(clippy::doc_markdown)]
124#![allow(clippy::module_name_repetitions)]
125
126mod archive;
127#[cfg(feature = "blocking")]
128pub mod blocking;
129pub mod configuration;
130mod error;
131pub mod extractor;
132pub mod hasher;
133pub mod matcher;
134pub mod repository;
135mod version;
136
137pub use archive::{extract, get_archive, get_version};
138pub use error::{Error, Result};
139pub use semver::{Version, VersionReq};
140pub use version::{ExactVersion, ExactVersionReq};