Skip to content

Commit 3e487fd

Browse files
committed
refactor!: remove bytes dependency
1 parent cc0fc5c commit 3e487fd

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

postgresql_archive/benches/archive.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use bytes::Bytes;
21
use criterion::{criterion_group, criterion_main, Criterion};
32
use postgresql_archive::blocking::{extract, get_archive};
43
use postgresql_archive::{Result, VersionReq, DEFAULT_POSTGRESQL_URL};
@@ -22,7 +21,7 @@ fn bench_extract(criterion: &mut Criterion) -> Result<()> {
2221
Ok(())
2322
}
2423

25-
fn extract_archive(archive: &Bytes) -> Result<()> {
24+
fn extract_archive(archive: &Vec<u8>) -> Result<()> {
2625
let out_dir = tempfile::tempdir()?.path().to_path_buf();
2726
create_dir_all(&out_dir)?;
2827
extract(archive, &out_dir)?;

postgresql_archive/src/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn acquire_lock(out_dir: &Path) -> Result<PathBuf> {
101101
/// Returns an error if the extraction fails.
102102
#[allow(clippy::cast_precision_loss)]
103103
#[instrument(skip(bytes))]
104-
pub async fn extract(bytes: Vec<u8>, out_dir: &Path) -> Result<()> {
104+
pub async fn extract(bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
105105
let input = BufReader::new(Cursor::new(bytes));
106106
let decoder = GzDecoder::new(input);
107107
let mut archive = Archive::new(decoder);

postgresql_archive/src/blocking/archive.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::{Version, VersionReq};
2-
use bytes::Bytes;
32
use std::path::Path;
43
use tokio::runtime::Runtime;
54

@@ -25,7 +24,7 @@ pub fn get_version(url: &str, version_req: &VersionReq) -> crate::Result<Version
2524
/// # Errors
2625
/// * If the archive is not found.
2726
/// * If the archive cannot be downloaded.
28-
pub fn get_archive(url: &str, version_req: &VersionReq) -> crate::Result<(Version, Bytes)> {
27+
pub fn get_archive(url: &str, version_req: &VersionReq) -> crate::Result<(Version, Vec<u8>)> {
2928
RUNTIME
3029
.handle()
3130
.block_on(async move { crate::get_archive(url, version_req).await })
@@ -35,7 +34,7 @@ pub fn get_archive(url: &str, version_req: &VersionReq) -> crate::Result<(Versio
3534
///
3635
/// # Errors
3736
/// Returns an error if the extraction fails.
38-
pub fn extract(bytes: &Bytes, out_dir: &Path) -> crate::Result<()> {
37+
pub fn extract(bytes: &Vec<u8>, out_dir: &Path) -> crate::Result<()> {
3938
RUNTIME
4039
.handle()
4140
.block_on(async move { crate::extract(bytes, out_dir).await })

postgresql_embedded/src/postgresql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl PostgreSQL {
157157
debug!("Using bundled installation archive");
158158
(
159159
self.settings.version.clone(),
160-
bytes::Bytes::copy_from_slice(crate::settings::ARCHIVE),
160+
crate::settings::ARCHIVE.to_vec(),
161161
)
162162
} else {
163163
let (version, bytes) =

0 commit comments

Comments
 (0)