Skip to content

Commit 881ca24

Browse files
committed
Make ConfigurationError lifetime free
Allows it to build on both sides of the breaking change in async-graphql and means we can get rid of the security warning on the repo. See async-graphql/async-graphql#1634 and CVE-2024-47614
1 parent 68b8372 commit 881ca24

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ license = "Apache-2.0"
88
unwrap_used = "deny"
99

1010
[dependencies]
11-
async-graphql = { version = "=7.0.9", features = ["tracing"] }
12-
async-graphql-axum = "=7.0.9"
11+
async-graphql = { version = "7.0.11", features = ["tracing"] }
12+
async-graphql-axum = "7.0.11"
1313
axum = "0.7.5"
1414
chrono = "0.4.38"
1515
clap = { version = "4.5.16", features = ["cargo", "derive", "env"] }

src/db_service.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ impl SqliteScanPathService {
288288
Ok(Self { pool })
289289
}
290290

291-
pub async fn current_configuration<'bl>(
291+
pub async fn current_configuration(
292292
&self,
293-
beamline: &'bl str,
294-
) -> Result<BeamlineConfiguration, ConfigurationError<'bl>> {
293+
beamline: &str,
294+
) -> Result<BeamlineConfiguration, ConfigurationError> {
295295
query_as!(
296296
DbBeamlineConfig,
297297
"SELECT * FROM beamline WHERE name = ?",
@@ -300,14 +300,14 @@ impl SqliteScanPathService {
300300
.fetch_optional(&self.pool)
301301
.await?
302302
.map(BeamlineConfiguration::from)
303-
.ok_or(ConfigurationError::MissingBeamline(beamline))
303+
.ok_or(ConfigurationError::MissingBeamline(beamline.into()))
304304
}
305305

306-
pub async fn next_scan_configuration<'bl>(
306+
pub async fn next_scan_configuration(
307307
&self,
308-
beamline: &'bl str,
308+
beamline: &str,
309309
current_high: Option<u32>,
310-
) -> Result<BeamlineConfiguration, ConfigurationError<'bl>> {
310+
) -> Result<BeamlineConfiguration, ConfigurationError> {
311311
let exp = current_high.unwrap_or(0);
312312
query_as!(
313313
DbBeamlineConfig,
@@ -318,7 +318,7 @@ impl SqliteScanPathService {
318318
.fetch_optional(&self.pool)
319319
.await?
320320
.map(BeamlineConfiguration::from)
321-
.ok_or(ConfigurationError::MissingBeamline(beamline))
321+
.ok_or(ConfigurationError::MissingBeamline(beamline.into()))
322322
}
323323

324324
#[cfg(test)]
@@ -352,12 +352,12 @@ mod error {
352352
use std::fmt::{self, Display};
353353

354354
#[derive(Debug)]
355-
pub enum ConfigurationError<'bl> {
356-
MissingBeamline(&'bl str),
355+
pub enum ConfigurationError {
356+
MissingBeamline(String),
357357
Db(sqlx::Error),
358358
}
359359

360-
impl Display for ConfigurationError<'_> {
360+
impl Display for ConfigurationError {
361361
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
362362
match self {
363363
ConfigurationError::MissingBeamline(bl) => {
@@ -368,7 +368,7 @@ mod error {
368368
}
369369
}
370370

371-
impl Error for ConfigurationError<'_> {
371+
impl Error for ConfigurationError {
372372
fn source(&self) -> Option<&(dyn Error + 'static)> {
373373
match self {
374374
ConfigurationError::MissingBeamline(_) => None,
@@ -377,7 +377,7 @@ mod error {
377377
}
378378
}
379379

380-
impl From<sqlx::Error> for ConfigurationError<'_> {
380+
impl From<sqlx::Error> for ConfigurationError {
381381
fn from(value: sqlx::Error) -> Self {
382382
Self::Db(value)
383383
}

0 commit comments

Comments
 (0)