Skip to content

Commit e3247ac

Browse files
committed
Use constants for benchmark request status strings
1 parent 2f1d1c2 commit e3247ac

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

database/src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,18 @@ pub enum BenchmarkRequestStatus {
805805
Completed,
806806
}
807807

808+
const WAITING_FOR_ARTIFACTS_STR: &str = "waiting_for_artifacts";
809+
const ARTIFACTS_READY_STR: &str = "artifacts_ready";
810+
const IN_PROGRESS_STR: &str = "in_progress";
811+
const COMPLETED_STR: &str = "completed";
812+
808813
impl BenchmarkRequestStatus {
809814
pub fn as_str(&self) -> &str {
810815
match self {
811-
BenchmarkRequestStatus::WaitingForArtifacts => "waiting_for_artifacts",
812-
BenchmarkRequestStatus::ArtifactsReady => "artifacts_ready",
813-
BenchmarkRequestStatus::InProgress => "in_progress",
814-
BenchmarkRequestStatus::Completed => "completed",
816+
BenchmarkRequestStatus::WaitingForArtifacts => WAITING_FOR_ARTIFACTS_STR,
817+
BenchmarkRequestStatus::ArtifactsReady => ARTIFACTS_READY_STR,
818+
BenchmarkRequestStatus::InProgress => IN_PROGRESS_STR,
819+
BenchmarkRequestStatus::Completed { .. } => COMPLETED_STR,
815820
}
816821
}
817822
}
@@ -831,10 +836,10 @@ impl<'a> tokio_postgres::types::FromSql<'a> for BenchmarkRequestStatus {
831836
let s: &str = <&str as tokio_postgres::types::FromSql>::from_sql(ty, raw)?;
832837

833838
match s {
834-
x if x == Self::WaitingForArtifacts.as_str() => Ok(Self::WaitingForArtifacts),
835-
x if x == Self::ArtifactsReady.as_str() => Ok(Self::ArtifactsReady),
836-
x if x == Self::InProgress.as_str() => Ok(Self::InProgress),
837-
x if x == Self::Completed.as_str() => Ok(Self::Completed),
839+
WAITING_FOR_ARTIFACTS_STR => Ok(Self::WaitingForArtifacts),
840+
ARTIFACTS_READY_STR => Ok(Self::ArtifactsReady),
841+
IN_PROGRESS_STR => Ok(Self::InProgress),
842+
COMPLETED_STR => Ok(Self::Completed),
838843
other => Err(format!("unknown benchmark_request_status '{other}'").into()),
839844
}
840845
}

0 commit comments

Comments
 (0)