@@ -805,17 +805,23 @@ pub enum BenchmarkRequestStatus {
805805 Completed ,
806806}
807807
808- impl fmt :: Display for BenchmarkRequestStatus {
809- fn fmt ( & self , f : & mut fmt :: Formatter < ' _ > ) -> fmt :: Result {
808+ impl BenchmarkRequestStatus {
809+ pub fn as_str ( & self ) -> & str {
810810 match self {
811- BenchmarkRequestStatus :: WaitingForArtifacts => write ! ( f , "waiting_for_artifacts" ) ,
812- BenchmarkRequestStatus :: ArtifactsReady => write ! ( f , "artifacts_ready" ) ,
813- BenchmarkRequestStatus :: InProgress => write ! ( f , "in_progress" ) ,
814- BenchmarkRequestStatus :: Completed => write ! ( f , "completed" ) ,
811+ BenchmarkRequestStatus :: WaitingForArtifacts => "waiting_for_artifacts" ,
812+ BenchmarkRequestStatus :: ArtifactsReady => "artifacts_ready" ,
813+ BenchmarkRequestStatus :: InProgress => "in_progress" ,
814+ BenchmarkRequestStatus :: Completed => "completed" ,
815815 }
816816 }
817817}
818818
819+ impl fmt:: Display for BenchmarkRequestStatus {
820+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
821+ f. write_str ( self . as_str ( ) )
822+ }
823+ }
824+
819825impl < ' a > tokio_postgres:: types:: FromSql < ' a > for BenchmarkRequestStatus {
820826 fn from_sql (
821827 ty : & tokio_postgres:: types:: Type ,
@@ -825,10 +831,10 @@ impl<'a> tokio_postgres::types::FromSql<'a> for BenchmarkRequestStatus {
825831 let s: & str = <& str as tokio_postgres:: types:: FromSql >:: from_sql ( ty, raw) ?;
826832
827833 match s {
828- "waiting_for_artifacts" => Ok ( Self :: WaitingForArtifacts ) ,
829- "artifacts_ready" => Ok ( Self :: ArtifactsReady ) ,
830- "in_progress" => Ok ( Self :: InProgress ) ,
831- "completed" => Ok ( Self :: Completed ) ,
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 ) ,
832838 other => Err ( format ! ( "unknown benchmark_request_status '{other}'" ) . into ( ) ) ,
833839 }
834840 }
@@ -856,30 +862,12 @@ pub enum BenchmarkRequestType {
856862 Release { tag : String } ,
857863}
858864
859- impl BenchmarkRequestType {
860- pub fn commit_type_str ( & self ) -> & str {
861- match self {
862- BenchmarkRequestType :: Try {
863- sha : _,
864- parent_sha : _,
865- pr : _,
866- } => "try" ,
867- BenchmarkRequestType :: Master {
868- sha : _,
869- parent_sha : _,
870- pr : _,
871- } => "master" ,
872- BenchmarkRequestType :: Release { tag : _ } => "release" ,
873- }
874- }
875- }
876-
877865impl fmt:: Display for BenchmarkRequestType {
878866 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
879867 match self {
880868 BenchmarkRequestType :: Try { .. } => write ! ( f, "try" ) ,
881869 BenchmarkRequestType :: Master { .. } => write ! ( f, "master" ) ,
882- BenchmarkRequestType :: Release { tag : _ } => write ! ( f, "release" ) ,
870+ BenchmarkRequestType :: Release { .. } => write ! ( f, "release" ) ,
883871 }
884872 }
885873}
@@ -975,19 +963,15 @@ impl BenchmarkRequest {
975963 BenchmarkRequestType :: Try { pr, .. } | BenchmarkRequestType :: Master { pr, .. } => {
976964 Some ( pr)
977965 }
978- BenchmarkRequestType :: Release { tag : _ } => None ,
966+ BenchmarkRequestType :: Release { .. } => None ,
979967 }
980968 }
981969
982- pub fn commit_type ( & self ) -> & str {
983- self . commit_type . commit_type_str ( )
984- }
985-
986970 pub fn parent_sha ( & self ) -> Option < & str > {
987971 match & self . commit_type {
988972 BenchmarkRequestType :: Try { parent_sha, .. } => parent_sha. as_deref ( ) ,
989973 BenchmarkRequestType :: Master { parent_sha, .. } => Some ( parent_sha) ,
990- BenchmarkRequestType :: Release { tag : _ } => None ,
974+ BenchmarkRequestType :: Release { .. } => None ,
991975 }
992976 }
993977}
0 commit comments