Skip to content

Commit

Permalink
Removes the boxed trait state machine pattern and replaces it with st…
Browse files Browse the repository at this point in the history
…ruct returns.

Boxed traits proved to be difficult to work with. On the user side: the buildpack user mostly interacts with associated methods on `BuildLog` they cannot be called unless the traits that implement them are in scope so the user was forced to have a `*` import. On the implementation side, boxed traits are limited. For example, there was no way to have an associated function that accepts a `Fn` or `FnOnce` to call it and return itself.

The boxed trait state machine pattern was a useful exercise in refining the shape of the API, but it is no longer bringing joy. With that, we wish it farewell.
  • Loading branch information
schneems committed Jan 24, 2024
1 parent ebb092c commit 3f928e7
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 242 deletions.
12 changes: 4 additions & 8 deletions libherokubuildpack/examples/print_style_guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use indoc::formatdoc;
use libherokubuildpack::output::style::{self, DEBUG_INFO, HELP};
#[allow(clippy::wildcard_imports)]
use libherokubuildpack::output::{
build_log::*,
build_log::BuildLog,
section_log::{log_step, log_step_stream, log_step_timed},
};
use std::io::stdout;
Expand Down Expand Up @@ -81,8 +81,7 @@ fn main() {
command
.stream_output(stream.io(), stream.io())
.expect("Implement real error handling in real apps");
log = stream.finish_timed_stream().end_section();
drop(log);
stream.finish_timed_stream().end_section();
}

{
Expand Down Expand Up @@ -174,10 +173,8 @@ fn main() {
}

{
let mut log = BuildLog::new(stdout()).buildpack_name("Formatting helpers");

log = log
.section("The style module")
let log = BuildLog::new(stdout()).buildpack_name("Formatting helpers");
log.section("The style module")
.step(&formatdoc! {"
Formatting helpers can be used to enhance log output:
"})
Expand Down Expand Up @@ -223,6 +220,5 @@ fn main() {
];

table.print(data);
drop(log);
}
}
Loading

0 comments on commit 3f928e7

Please sign in to comment.