@@ -20,31 +20,21 @@ pub const DEFAULT_API_URL: &str = "https://api.harmont.dev";
2020/// Closed set parsed at the config boundary so invalid values are rejected at
2121/// deserialize time instead of mis-dispatching later, and every consumer match
2222/// is exhaustively checked by the compiler.
23- #[ derive( Debug , Default , Copy , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
23+ ///
24+ /// The `#[display(...)]` strings are the stable lowercase wire/CLI names and
25+ /// must match the `#[serde(rename_all = "lowercase")]` representation.
26+ #[ derive(
27+ Debug , Default , Copy , Clone , PartialEq , Eq , Serialize , Deserialize , derive_more:: Display ,
28+ ) ]
2429#[ serde( rename_all = "lowercase" ) ]
2530pub enum Backend {
2631 #[ default]
32+ #[ display( "docker" ) ]
2733 Docker ,
34+ #[ display( "cloud" ) ]
2835 Cloud ,
2936}
3037
31- impl Backend {
32- /// Stable lowercase wire/CLI name (matches the `serde` representation).
33- #[ must_use]
34- pub const fn as_str ( self ) -> & ' static str {
35- match self {
36- Self :: Docker => "docker" ,
37- Self :: Cloud => "cloud" ,
38- }
39- }
40- }
41-
42- impl std:: fmt:: Display for Backend {
43- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
44- f. write_str ( self . as_str ( ) )
45- }
46- }
47-
4838/// Derive the SPA (dashboard) base URL from the API base.
4939///
5040/// The CLI talks to `api.harmont.dev`, but a human clicks through to the
@@ -315,6 +305,12 @@ org = "project-org"
315305 assert_eq ! ( cfg. preferences. format, "json" ) ;
316306 }
317307
308+ #[ test]
309+ fn backend_display_matches_wire_strings ( ) {
310+ assert_eq ! ( Backend :: Docker . to_string( ) , "docker" ) ;
311+ assert_eq ! ( Backend :: Cloud . to_string( ) , "cloud" ) ;
312+ }
313+
318314 #[ test]
319315 fn backend_defaults_docker_and_parses_and_layers ( ) {
320316 // default
0 commit comments