Repository navigation
refactor(protocol): derive image format name parsing - #503
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open finding
What changed in this PR
Refactors ImageFormatName parsing to be derived from the enum definition (via strum::EnumString) and expands tests to pin both recognized formats and “unknown” passthrough behavior.
Changes:
- Derive
strum::EnumStringonImageFormatNamewith kebab-case serialization and a#[strum(default)] Other(String)fallback. - Simplify
ImageFormatName::from_lisp_typeto delegate to the derived parsing. - Expand diagnostic tests to cover all known symbols plus unknown/case/whitespace/Unicode inputs.
| File | Description |
|---|---|
| crates/neomacs-display-protocol/src/image_diagnostic.rs | Switches handwritten string matching to strum-derived enum parsing with a default Other(String) fallback. |
| crates/neomacs-display-protocol/src/image_diagnostic/tests/diagnostic_test.rs | Reworks tests into table-driven cases for all known types and adds coverage for unknown symbol preservation. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| "native-image" => Self::NativeImage, | ||
| other => Self::Other(other.to_owned()), | ||
| } | ||
| Self::from(name) |

ImageFormatName::from_lisp_typeduplicated the enum’s 12 known image types in a handwritten string parser. Derivestrum::EnumStringwith kebab-case names and#[strum(default)] Other(String)so the enum declaration defines recognition and captures unknown inputs.Keep the existing infallible
from_lisp_typeAPI by forwarding to the generatedFrom<&str>implementation. Preserve exact case-sensitive recognition and unknown-name contents. GNU diagnostic spellings and signature-mismatch policy remain unchanged. Reuse the existing strum dependency.Validation: all 852 protocol library tests pass. Tests pin all 12 known symbols and diagnostic spellings, plus unknown inputs including case changes, underscores, whitespace, empty strings, and Unicode. Formatting and diff checks pass. Tests remain in
image_diagnostic/tests/diagnostic_test.rs.