killercup / killercup/convey

Refactor internal message structure?

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
design decision required
Dominant language
Rust
Stars
38
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Right now, we use locking and a mutable reference to the target to output stuff. This is not very nice, but allows us to work around using termcolor for Windows support.

Targets can receive multiple messages per item to print, and each message will need to own its data (or be `'static`). Another approach would be to have one message per item that contains a vector of control instructions, that the target get execute to get the wanted output.

For human output, I'm thinking of a structure like this:

```rust
enum Part {
Command(Cmd),
// Option 1: Just send owned strings
Content(String),
// Option 2: Use a buffer in the StringArea and refer to slices of it
Content { start: usize, end: usize },
}

struct StringArena {
content: Vec
// For option 2:
buffer: String,
}

enum Cmd {
ResetStyle,
Bold,
Underline,
Foreground(Color),
Background(Color),
ClearLine,
}

struct Color(termcolor::Color)
```

Option 2 would have the additional advantage of being trivial to convert to plain-text – just return the string buffer.

Contributor guide

Open the contributing guide

Research direction

No file or test is named; start by tracing the locking, mutable target reference, and termcolor Windows workaround in the output path. Compare the owned-string and StringArena alternatives for multiple messages per item and plain-text conversion. Done means the message representation and ownership behavior are decided and implemented with human and machine output validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.