aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_server/database/mod.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:50:54 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:50:54 +0200
commit6723829a3398b3c9dd6dc6ae79124f46000606ee (patch)
treea1ec535eddd711a4557e4bcc5b94382c3623504c /crates/turtle/src/atuin_server/database/mod.rs
parentchore(treewide): Cleanup themes (diff)
downloadatuin-6723829a3398b3c9dd6dc6ae79124f46000606ee.zip
chore(treewide): Remove `cargo` warnings to 0
There are still the `clippy` warnings, but they are for a future date.
Diffstat (limited to 'crates/turtle/src/atuin_server/database/mod.rs')
-rw-r--r--crates/turtle/src/atuin_server/database/mod.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/turtle/src/atuin_server/database/mod.rs b/crates/turtle/src/atuin_server/database/mod.rs
index bb64767a..43fe5c3b 100644
--- a/crates/turtle/src/atuin_server/database/mod.rs
+++ b/crates/turtle/src/atuin_server/database/mod.rs
@@ -14,29 +14,29 @@ pub(crate) enum DbError {
impl Display for DbError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
- DbError::NotFound => write!(f, "Not found"),
- DbError::Other(report) => write!(f, "Other: {report}"),
+ Self::NotFound => write!(f, "Not found"),
+ Self::Other(report) => write!(f, "Other: {report}"),
}
}
}
impl From<time::error::ComponentRange> for DbError {
fn from(error: time::error::ComponentRange) -> Self {
- DbError::Other(error.into())
+ Self::Other(error.into())
}
}
impl From<time::error::Error> for DbError {
fn from(error: time::error::Error) -> Self {
- DbError::Other(error.into())
+ Self::Other(error.into())
}
}
impl From<sqlx::Error> for DbError {
fn from(error: sqlx::Error) -> Self {
match error {
- sqlx::Error::RowNotFound => DbError::NotFound,
- error => DbError::Other(error.into()),
+ sqlx::Error::RowNotFound => Self::NotFound,
+ error => Self::Other(error.into()),
}
}
}
@@ -54,6 +54,7 @@ pub(crate) enum DbType {
#[derive(Clone, Deserialize, Serialize)]
pub(crate) struct DbSettings {
pub(crate) db_uri: String,
+
/// Optional URI for read replicas. If set, read-only queries will use this connection.
pub(crate) read_db_uri: Option<String>,
}
@@ -69,12 +70,13 @@ impl DbSettings {
}
fn redact_db_uri(uri: &str) -> String {
- url::Url::parse(uri)
- .map(|mut url| {
- let _ = url.set_password(Some("****"));
+ url::Url::parse(uri).map_or_else(
+ |_| uri.to_string(),
+ |mut url| {
+ url.set_password(Some("****")).expect("should be possible");
url.to_string()
- })
- .unwrap_or_else(|_| uri.to_string())
+ },
+ )
}
// Do our best to redact passwords so they're not logged in the event of an error.