Skip to content

Commit 087b7a9

Browse files
committed
refactor: use SmartDefault for StepLogWriter
1 parent 8a856c2 commit 087b7a9

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

crates/hm/src/orchestrator/docker_host_fns.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ pub(crate) async fn exec_impl(args: DockerExecArgs) -> Result<i32> {
122122
// Emit StepLog events for each line written; the writer below
123123
// forwards bytes into the event bus tagged with the current
124124
// thread-local step_id set by the scheduler.
125-
let mut writer = StepLogWriter::new();
125+
let mut writer = StepLogWriter::default();
126126

127127
// Future doing the exec; we race it against cancellation.
128128
let cancel = s.cancel.clone();
@@ -184,17 +184,13 @@ pub(crate) async fn stop_remove_impl(container_id: String) {
184184

185185
/// Streams bytes from a Docker exec into per-line `StepLog` events on
186186
/// the event bus. Buffers partial lines until a `\n` arrives.
187+
#[derive(smart_default::SmartDefault)]
187188
struct StepLogWriter {
189+
#[default(Vec::with_capacity(8192))]
188190
buf: Vec<u8>,
189191
}
190192

191193
impl StepLogWriter {
192-
fn new() -> Self {
193-
Self {
194-
buf: Vec::with_capacity(8192),
195-
}
196-
}
197-
198194
fn flush_line(line: &[u8]) {
199195
let Some(state) = current() else { return };
200196
let Some(step_id) = crate::plugin::host_fns::current_step_id() else {

0 commit comments

Comments
 (0)