update the macro to look more like an enum

This commit is contained in:
Tamo 2024-12-11 16:23:21 +01:00
parent 786b0fabea
commit 1f54dfa883
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69

View File

@ -56,11 +56,11 @@ impl ProcessingTasks {
} }
macro_rules! make_enum_progress { macro_rules! make_enum_progress {
(enum $name:ident: $(- $variant:ident)+ ) => { ($visibility:vis enum $name:ident { $($variant:ident,)+ }) => {
#[repr(u8)] #[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Sequence)]
#[allow(clippy::enum_variant_names)] #[allow(clippy::enum_variant_names)]
pub enum $name { $visibility enum $name {
$($variant),+ $($variant),+
} }
@ -100,98 +100,112 @@ macro_rules! make_atomic_progress {
} }
make_enum_progress! { make_enum_progress! {
enum BatchProgress: pub enum BatchProgress {
- ProcessingTasks ProcessingTasks,
- WritingTasksToDisk WritingTasksToDisk,
}
} }
make_enum_progress! { make_enum_progress! {
enum TaskCancelationProgress: pub enum TaskCancelationProgress {
- RetrievingTasks RetrievingTasks,
- UpdatingTasks UpdatingTasks,
}
} }
make_enum_progress! { make_enum_progress! {
enum TaskDeletionProgress: pub enum TaskDeletionProgress {
- DeletingTasksDateTime DeletingTasksDateTime,
- DeletingTasksMetadata DeletingTasksMetadata,
- DeletingTasks DeletingTasks,
- DeletingBatches DeletingBatches,
}
} }
make_enum_progress! { make_enum_progress! {
enum SnapshotCreationProgress: pub enum SnapshotCreationProgress {
- StartTheSnapshotCreation StartTheSnapshotCreation,
- SnapshotTheIndexScheduler SnapshotTheIndexScheduler,
- SnapshotTheUpdateFiles SnapshotTheUpdateFiles,
- SnapshotTheIndexes SnapshotTheIndexes,
- SnapshotTheApiKeys SnapshotTheApiKeys,
- CreateTheTarball CreateTheTarball,
}
} }
make_enum_progress! { make_enum_progress! {
enum DumpCreationProgress: pub enum DumpCreationProgress {
- StartTheDumpCreation StartTheDumpCreation,
- DumpTheApiKeys DumpTheApiKeys,
- DumpTheTasks DumpTheTasks,
- DumpTheIndexes DumpTheIndexes,
- DumpTheExperimentalFeatures DumpTheExperimentalFeatures,
- CompressTheDump CompressTheDump,
}
} }
make_enum_progress! { make_enum_progress! {
enum CreateIndexProgress: pub enum CreateIndexProgress {
- CreatingTheIndex CreatingTheIndex,
}
} }
make_enum_progress! { make_enum_progress! {
enum UpdateIndexProgress: pub enum UpdateIndexProgress {
- UpdatingTheIndex UpdatingTheIndex,
}
} }
make_enum_progress! { make_enum_progress! {
enum DeleteIndexProgress: pub enum DeleteIndexProgress {
- DeletingTheIndex DeletingTheIndex,
}
} }
make_enum_progress! { make_enum_progress! {
enum SwappingTheIndexes: pub enum SwappingTheIndexes {
- EnsuringCorrectnessOfTheSwap EnsuringCorrectnessOfTheSwap,
- SwappingTheIndexes SwappingTheIndexes,
}
} }
make_enum_progress! { make_enum_progress! {
enum InnerSwappingTwoIndexes: pub enum InnerSwappingTwoIndexes {
- RetrieveTheTasks RetrieveTheTasks,
- UpdateTheTasks UpdateTheTasks,
- UpdateTheIndexesMetadata UpdateTheIndexesMetadata,
}
} }
make_enum_progress! { make_enum_progress! {
enum DocumentOperationProgress: pub enum DocumentOperationProgress {
- RetrievingConfig RetrievingConfig,
- ComputingTheChanges ComputingTheChanges,
- Indexing Indexing,
}
} }
make_enum_progress! { make_enum_progress! {
enum DocumentEditionProgress: pub enum DocumentEditionProgress {
- RetrievingConfig RetrievingConfig,
- ComputingTheChanges ComputingTheChanges,
- Indexing Indexing,
}
} }
make_enum_progress! { make_enum_progress! {
enum DocumentDeletionProgress: pub enum DocumentDeletionProgress {
- RetrievingConfig RetrievingConfig,
- DeleteDocuments DeleteDocuments,
- Indexing Indexing,
}
} }
make_enum_progress! { make_enum_progress! {
enum SettingsProgress: pub enum SettingsProgress {
- RetrievingAndMergingTheSettings RetrievingAndMergingTheSettings,
- ApplyTheSettings ApplyTheSettings,
}
} }
make_atomic_progress!(Task alias AtomicTaskStep => "task" ); make_atomic_progress!(Task alias AtomicTaskStep => "task" );