Skip to content

Commit 47c10f1

Browse files
Merge pull request #161 from theseus-rs/replace-regex-with-regex-lite
chore: replace regex with regex-lite to reduce dependencies
2 parents 283fde0 + 6421c81 commit 47c10f1

File tree

18 files changed

+66
-42
lines changed

18 files changed

+66
-42
lines changed

Cargo.lock

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ postgres = "0.19.9"
4545
quick-xml = "0.37.1"
4646
r2d2_postgres = "0.18.1"
4747
rand = "0.8.5"
48-
regex = "1.11.1"
48+
regex-lite = "0.1.6"
4949
reqwest = { version = "0.12.12", default-features = false }
5050
reqwest-middleware = "0.4.0"
5151
reqwest-retry = "0.7.0"

postgresql_archive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ liblzma = { workspace = true }
1919
md-5 = { workspace = true, optional = true }
2020
num-format = { workspace = true }
2121
quick-xml = { workspace = true, features = ["serialize"], optional = true }
22-
regex = { workspace = true }
22+
regex-lite = { workspace = true }
2323
reqwest = { workspace = true, default-features = false, features = ["json", "stream"] }
2424
reqwest-middleware = { workspace = true }
2525
reqwest-retry = { workspace = true }

postgresql_archive/src/archive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use crate::error::Result;
55
use crate::{extractor, repository};
6-
use regex::Regex;
6+
use regex_lite::Regex;
77
use semver::{Version, VersionReq};
88
use std::path::{Path, PathBuf};
99
use tracing::instrument;

postgresql_archive/src/configuration/theseus/extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::extractor::{tar_gz_extract, ExtractDirectories};
22
use crate::Error::Unexpected;
33
use crate::Result;
4-
use regex::Regex;
4+
use regex_lite::Regex;
55
use std::fs::{create_dir_all, remove_dir_all, remove_file, rename};
66
use std::path::{Path, PathBuf};
77
use std::thread::sleep;

postgresql_archive/src/configuration/zonky/extractor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::extractor::{tar_xz_extract, ExtractDirectories};
22
use crate::Error::Unexpected;
33
use crate::Result;
4-
use regex::Regex;
4+
use regex_lite::Regex;
55
use std::fs::{create_dir_all, remove_dir_all, remove_file, rename};
66
use std::io::Cursor;
77
use std::path::{Path, PathBuf};

postgresql_archive/src/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ pub enum Error {
4848
VersionNotFound(String),
4949
}
5050

51-
/// Converts a [`regex::Error`] into an [`ParseError`](Error::ParseError)
52-
impl From<regex::Error> for Error {
53-
fn from(error: regex::Error) -> Self {
51+
/// Converts a [`regex_lite::Error`] into an [`ParseError`](Error::ParseError)
52+
impl From<regex_lite::Error> for Error {
53+
fn from(error: regex_lite::Error) -> Self {
5454
Error::ParseError(error.to_string())
5555
}
5656
}
@@ -125,9 +125,9 @@ mod test {
125125

126126
#[test]
127127
fn test_from_regex_error() {
128-
let regex_error = regex::Error::Syntax("test".to_string());
128+
let regex_error = regex_lite::Regex::new("(?=a)").expect_err("regex error");
129129
let error = Error::from(regex_error);
130-
assert_eq!(error.to_string(), "test");
130+
assert_eq!(error.to_string(), "look-around is not supported");
131131
}
132132

133133
#[tokio::test]

postgresql_archive/src/extractor/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{Error, Result};
2-
use regex::Regex;
2+
use regex_lite::Regex;
33
use std::fmt::Display;
44
use std::path::PathBuf;
55

postgresql_archive/src/extractor/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn get(url: &str) -> Result<ExtractFn> {
9898
#[cfg(test)]
9999
mod tests {
100100
use super::*;
101-
use regex::Regex;
101+
use regex_lite::Regex;
102102

103103
#[test]
104104
fn test_register() -> Result<()> {

postgresql_archive/src/repository/github/repository.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::Error::{
88
use crate::{hasher, matcher, Result};
99
use async_trait::async_trait;
1010
use futures_util::StreamExt;
11-
use regex::Regex;
11+
use regex_lite::Regex;
1212
use reqwest::header::HeaderMap;
1313
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
1414
use reqwest_retry::policies::ExponentialBackoff;

0 commit comments

Comments
 (0)