Change EmptyLayerCause::{InvalidMetadataAction,RestoredLayerAction}
to be tuple enum variant
#849
Labels
EmptyLayerCause::{InvalidMetadataAction,RestoredLayerAction}
to be tuple enum variant
#849
Currently
EmptyLayerCause::InvalidMetadataAction
andEmptyLayerCause::RestoredLayerAction
are defined as struct enum variants with a singlecause
field:libcnb.rs/libcnb/src/layer/struct_api/mod.rs
Lines 81 to 94 in 3fa2c6c
This
cause
field is derived from the return value from theinvalid_metadata_action
andrestored_layer_action
functions.However, I don't think it's ideal to name it
cause
, since:invalid_metadata_action
andrestored_layer_action
can be anything - it doesn't have to be related to the "cause" at all. eg: A layer could be implemented to always returnRestoredLayerAction::DeleteLayer
no matter what, but include some piece of metadata from the old layer (eg the runtime version from the last successful build) for use outside ofrestored_layer_action
. In which cause calling it "cause" is not accurate.restored_layer_action
is technically a "cause", the named struct field ofcause
isn't accurate when there are multiple reasons for invalidation. For example, I have to rename the field to the pluralreasons
, which is a bit clunky:EmptyLayerCause::RestoredLayerAction { cause: reasons }
(see here).If these enum variants instead used a tuple type type, the naming of the variable is left up to the author:
If we do this, there are a few other places where we'd want to replace "cause" references too:
libcnb.rs/libcnb/src/layer/struct_api/mod.rs
Lines 70 to 107 in 3fa2c6c
The text was updated successfully, but these errors were encountered: