Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ reqwest-retry = "0.6.1"
reqwest-tracing = "0.5.3"
semver = "1.0.23"
serde = "1.0.207"
serde_json = "1.0.124"
serde_json = "1.0.128"
sha1 = "0.10.6"
sha2 = "0.10.8"
sqlx = { version = "0.8.2", default-features = false, features = ["postgres"] }
Expand Down
1 change: 1 addition & 0 deletions examples/archive_async/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use postgresql_archive::configuration::theseus;
Expand Down
1 change: 1 addition & 0 deletions examples/archive_sync/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use postgresql_archive::blocking::{extract, get_archive};
Expand Down
1 change: 1 addition & 0 deletions examples/axum_embedded/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
12 changes: 8 additions & 4 deletions examples/diesel_embedded/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use crate::models::{NewPost, Post};
use diesel::r2d2::{ConnectionManager, Pool};
use diesel::PgConnection;
use diesel::{PgConnection, RunQueryDsl, SelectableHelper};
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use postgresql_embedded::{PostgreSQL, Result, Settings, VersionReq};

mod models;
pub mod schema;

use self::models::*;
use diesel::prelude::*;

const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations/");
#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -51,6 +51,10 @@ async fn main() -> Result<()> {
postgresql.stop().await
}

/// Create a new post
///
/// # Panics
/// if the post cannot be saved
pub fn create_post(conn: &mut PgConnection, title: &str, body: &str) -> Post {
use crate::schema::posts;

Expand Down
1 change: 1 addition & 0 deletions examples/download_progress_bar/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
1 change: 1 addition & 0 deletions examples/embedded_async/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use postgresql_embedded::{PostgreSQL, Result, Settings, VersionReq};
Expand Down
1 change: 1 addition & 0 deletions examples/embedded_sync/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use postgresql_embedded::blocking::PostgreSQL;
Expand Down
1 change: 1 addition & 0 deletions examples/portal_corp_extension/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
1 change: 1 addition & 0 deletions examples/postgres_embedded/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
1 change: 1 addition & 0 deletions examples/sqlx_embedded/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
1 change: 1 addition & 0 deletions examples/tensor_chord_extension/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use anyhow::Result;
Expand Down
1 change: 1 addition & 0 deletions examples/zonky/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]

use postgresql_archive::configuration::zonky;
Expand Down
1 change: 0 additions & 1 deletion postgresql_archive/src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub async fn get_archive(url: &str, version_req: &VersionReq) -> Result<(Version
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::cast_precision_loss)]
#[instrument(skip(bytes))]
pub async fn extract(url: &str, bytes: &Vec<u8>, out_dir: &Path) -> Result<Vec<PathBuf>> {
let extractor_fn = extractor::registry::get(url)?;
Expand Down
4 changes: 3 additions & 1 deletion postgresql_archive/src/blocking/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pub fn get_version(url: &str, version_req: &VersionReq) -> crate::Result<Version
}

/// Gets the archive for a given [version requirement](VersionReq) that passes the default
/// matcher. If no archive is found for the [version requirement](VersionReq) and matcher then
/// matcher.
///
/// If no archive is found for the [version requirement](VersionReq) and matcher then
/// an [error](crate::error::Error) is returned.
///
/// # Errors
Expand Down
1 change: 0 additions & 1 deletion postgresql_archive/src/configuration/theseus/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use tracing::{debug, instrument, warn};
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::cast_precision_loss)]
#[instrument(skip(bytes))]
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
let out_dir = extract_directories.get_path(".")?;
Expand Down
1 change: 0 additions & 1 deletion postgresql_archive/src/configuration/theseus/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use semver::Version;
///
/// # Errors
/// * If the asset matcher fails.
#[allow(clippy::unnecessary_wraps)]
pub fn matcher(_url: &str, name: &str, version: &Version) -> crate::Result<bool> {
let target = target_triple::TARGET;
let expected_name = format!("postgresql-{version}-{target}.tar.gz");
Expand Down
3 changes: 1 addition & 2 deletions postgresql_archive/src/configuration/zonky/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use zip::ZipArchive;
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::case_sensitive_file_extension_comparisons)]
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::case_sensitive_file_extension_comparisons)]
#[instrument(skip(bytes))]
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
let out_dir = extract_directories.get_path(".")?;
Expand Down
1 change: 0 additions & 1 deletion postgresql_archive/src/configuration/zonky/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::env;
///
/// # Errors
/// * If the asset matcher fails.
#[allow(clippy::unnecessary_wraps)]
pub fn matcher(_url: &str, name: &str, version: &Version) -> Result<bool> {
let os = get_os();
let arch = get_arch();
Expand Down
3 changes: 1 addition & 2 deletions postgresql_archive/src/configuration/zonky/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Zonky {
///
/// # Errors
/// * If the URL is invalid.
#[allow(clippy::new_ret_no_self)]
#[expect(clippy::new_ret_no_self)]
pub fn new(_url: &str) -> Result<Box<dyn Repository>> {
let os = get_os();
let arch = get_arch();
Expand All @@ -48,7 +48,6 @@ impl Repository for Zonky {
}

#[instrument]
#[allow(clippy::cast_precision_loss)]
async fn get_archive(&self, version_req: &VersionReq) -> Result<Archive> {
self.maven.get_archive(version_req).await
}
Expand Down
4 changes: 1 addition & 3 deletions postgresql_archive/src/extractor/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type SupportsFn = fn(&str) -> Result<bool>;
type ExtractFn = fn(&Vec<u8>, ExtractDirectories) -> Result<Vec<PathBuf>>;

/// Singleton struct to store extractors
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
struct RepositoryRegistry {
extractors: Vec<(Arc<RwLock<SupportsFn>>, Arc<RwLock<ExtractFn>>)>,
}
Expand Down Expand Up @@ -63,7 +63,6 @@ impl RepositoryRegistry {
impl Default for RepositoryRegistry {
/// Creates a new repository registry with the default repositories registered.
fn default() -> Self {
#[allow(unused_mut)]
let mut registry = Self::new();
#[cfg(feature = "theseus")]
registry.register(|url| Ok(url.starts_with(theseus::URL)), theseus::extract);
Expand All @@ -77,7 +76,6 @@ impl Default for RepositoryRegistry {
///
/// # Errors
/// * If the registry is poisoned.
#[allow(dead_code)]
pub fn register(supports_fn: SupportsFn, extractor_fn: ExtractFn) -> Result<()> {
let mut registry = REGISTRY
.lock()
Expand Down
2 changes: 1 addition & 1 deletion postgresql_archive/src/extractor/tar_gz_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing::{debug, instrument, warn};
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
#[instrument(skip(bytes))]
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
let mut files = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion postgresql_archive/src/extractor/tar_xz_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing::{debug, instrument, warn};
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
#[instrument(skip(bytes))]
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
let mut files = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion postgresql_archive/src/extractor/zip_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use zip::ZipArchive;
///
/// # Errors
/// Returns an error if the extraction fails.
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
#[instrument(skip(bytes))]
pub fn extract(bytes: &Vec<u8>, extract_directories: ExtractDirectories) -> Result<Vec<PathBuf>> {
let mut files = Vec::new();
Expand Down
5 changes: 1 addition & 4 deletions postgresql_archive/src/hasher/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::hasher::md5;
use crate::hasher::sha1;
#[cfg(feature = "sha2")]
use crate::hasher::sha2_256;
#[allow(unused_imports)]
#[cfg(feature = "sha2")]
use crate::hasher::sha2_512;
#[cfg(feature = "maven")]
Expand All @@ -22,7 +21,7 @@ pub type SupportsFn = fn(&str, &str) -> Result<bool>;
pub type HasherFn = fn(&Vec<u8>) -> Result<String>;

/// Singleton struct to store hashers
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
struct HasherRegistry {
hashers: Vec<(Arc<RwLock<SupportsFn>>, Arc<RwLock<HasherFn>>)>,
}
Expand Down Expand Up @@ -73,7 +72,6 @@ impl HasherRegistry {
impl Default for HasherRegistry {
/// Creates a new hasher registry with the default hashers registered.
fn default() -> Self {
#[allow(unused_mut)]
let mut registry = Self::new();
#[cfg(feature = "theseus")]
registry.register(
Expand Down Expand Up @@ -110,7 +108,6 @@ impl Default for HasherRegistry {
///
/// # Errors
/// * If the registry is poisoned.
#[allow(dead_code)]
pub fn register(supports_fn: SupportsFn, hasher_fn: HasherFn) -> Result<()> {
let mut registry = REGISTRY
.lock()
Expand Down
1 change: 1 addition & 0 deletions postgresql_archive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
//! PostgreSQL is covered under [The PostgreSQL License](https://opensource.org/licenses/postgresql).

#![forbid(unsafe_code)]
#![forbid(clippy::allow_attributes)]
#![deny(clippy::pedantic)]
#![allow(clippy::doc_markdown)]
#![allow(clippy::module_name_repetitions)]
Expand Down
4 changes: 1 addition & 3 deletions postgresql_archive/src/matcher/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub type SupportsFn = fn(&str) -> Result<bool>;
pub type MatcherFn = fn(&str, &str, &Version) -> Result<bool>;

/// Singleton struct to store matchers
#[allow(clippy::type_complexity)]
#[expect(clippy::type_complexity)]
struct MatchersRegistry {
matchers: Vec<(Arc<RwLock<SupportsFn>>, Arc<RwLock<MatcherFn>>)>,
}
Expand Down Expand Up @@ -64,7 +64,6 @@ impl MatchersRegistry {
impl Default for MatchersRegistry {
/// Creates a new matcher registry with the default matchers registered.
fn default() -> Self {
#[allow(unused_mut)]
let mut registry = Self::new();
#[cfg(feature = "theseus")]
registry.register(|url| Ok(url == theseus::URL), theseus::matcher);
Expand All @@ -79,7 +78,6 @@ impl Default for MatchersRegistry {
///
/// # Errors
/// * If the registry is poisoned.
#[allow(dead_code)]
pub fn register(supports_fn: SupportsFn, matcher_fn: MatcherFn) -> Result<()> {
let mut registry = REGISTRY
.lock()
Expand Down
6 changes: 3 additions & 3 deletions postgresql_archive/src/repository/github/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl GitHub {
///
/// # Errors
/// * If the URL is invalid.
#[allow(clippy::new_ret_no_self)]
#[expect(clippy::new_ret_no_self)]
pub fn new(url: &str) -> Result<Box<dyn Repository>> {
let parsed_url = Url::parse(url)?;
let path = parsed_url.path().trim_start_matches('/');
Expand Down Expand Up @@ -216,7 +216,7 @@ impl Repository for GitHub {
}

#[instrument]
#[allow(clippy::cast_precision_loss)]
#[expect(clippy::cast_precision_loss)]
async fn get_archive(&self, version_req: &VersionReq) -> Result<Archive> {
let release = self.get_release(version_req).await?;
let version = Self::get_version_from_tag_name(release.tag_name.as_str())?;
Expand Down Expand Up @@ -283,7 +283,7 @@ impl Repository for GitHub {
struct GithubMiddleware;

impl GithubMiddleware {
#[allow(clippy::unnecessary_wraps)]
#[expect(clippy::unnecessary_wraps)]
fn add_headers(request: &mut Request) -> Result<()> {
let headers = request.headers_mut();
headers.append(
Expand Down
Loading