chore: release v0.2.0#111
Merged
Merged
Conversation
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 CI must passWonderful, this rule succeeded.All CI checks must pass. This protection prevents manual merges that bypass the merge queue.
🟢 Do not merge outdated PRsWonderful, this rule succeeded.Make sure PRs are within 10 commits of the base branch before merging
|
Contributor
|
Documentation Updates 6 document(s) were updated by changes in this PR: api-referenceView Changes@@ -223,7 +223,7 @@
| Variant | Description |
|---------|-------------|
-| `Byte { signed }` | Single byte with explicit signedness |
+| `Byte { signed }` | Single byte with explicit signedness (struct variant since v0.2.0; previously unit variant) |
| `Short { endian, signed }` | 16-bit integer |
| `Long { endian, signed }` | 32-bit integer |
| `String { max_length }` | String data |
@@ -240,10 +240,10 @@
|---------|-------------|
| `Equal` | Equality comparison (`=`) |
| `NotEqual` | Inequality comparison (`!=`) |
-| `LessThan` | Less than comparison (`<`) |
-| `GreaterThan` | Greater than comparison (`>`) |
-| `LessEqual` | Less than or equal comparison (`<=`) |
-| `GreaterEqual` | Greater than or equal comparison (`>=`) |
+| `LessThan` | Less than comparison (`<`) (added in v0.2.0) |
+| `GreaterThan` | Greater than comparison (`>`) (added in v0.2.0) |
+| `LessEqual` | Less than or equal comparison (`<=`) (added in v0.2.0) |
+| `GreaterEqual` | Greater than or equal comparison (`>=`) (added in v0.2.0) |
| `BitwiseAnd` | Bitwise AND |
| `BitwiseAndMask(u64)` | Bitwise AND with mask |
@@ -477,6 +477,12 @@
- **Minimum Rust Version**: 1.85
- **Edition**: 2024
- **License**: Apache-2.0
+- **Current Version**: 0.2.0
+
+### Breaking Changes in v0.2.0
+
+- `TypeKind::Byte` changed from a unit variant to a struct variant `Byte { signed }` to support explicit signedness
+- Added comparison operators: `LessThan`, `GreaterThan`, `LessEqual`, `GreaterEqual` to the `Operator` enum (breaking change due to exhaustive enum)
For complete API documentation with examples, run:
API_REFERENCEView Changes@@ -298,11 +298,13 @@
| Variant | Description |
|---------|-------------|
-| `Byte { signed }` | Single byte with explicit signedness |
+| `Byte { signed }` | Single byte with explicit signedness (changed in v0.2.0) |
| `Short { endian, signed }` | 16-bit integer |
| `Long { endian, signed }` | 32-bit integer |
| `String { max_length }` | String data |
+**Version Note:** In v0.2.0, the `Byte` variant changed from a unit variant to a struct variant with a `signed` field.
+
#### Operator
Comparison operators.
@@ -315,12 +317,14 @@
|---------|-------------|
| `Equal` | Equality comparison (`=` or `==`) |
| `NotEqual` | Inequality comparison (`!=` or `<>`) |
-| `LessThan` | Less than comparison (`<`) |
-| `GreaterThan` | Greater than comparison (`>`) |
-| `LessEqual` | Less than or equal comparison (`<=`) |
-| `GreaterEqual` | Greater than or equal comparison (`>=`) |
+| `LessThan` | Less than comparison (`<`) (added in v0.2.0) |
+| `GreaterThan` | Greater than comparison (`>`) (added in v0.2.0) |
+| `LessEqual` | Less than or equal comparison (`<=`) (added in v0.2.0) |
+| `GreaterEqual` | Greater than or equal comparison (`>=`) (added in v0.2.0) |
| `BitwiseAnd` | Bitwise AND (`&`) |
| `BitwiseAndMask(u64)` | Bitwise AND with mask value |
+
+**Version Note:** The comparison operators `LessThan`, `GreaterThan`, `LessEqual`, and `GreaterEqual` were added in v0.2.0.
#### Value
ast-structuresView Changes@@ -164,6 +164,8 @@
The `TypeKind` enum specifies how to interpret bytes at the given offset:
+> **Breaking Change in v0.2.0:** The `Byte` variant changed from a unit variant (`Byte`) to a struct variant (`Byte { signed: bool }`). Code that pattern-matches exhaustively on `TypeKind` requires updates.
+
### Numeric Types
```rust
@@ -235,6 +237,8 @@
BitwiseAndMask(u64), // & (bitwise AND with mask value)
}
```
+
+> **Added in v0.2.0:** The comparison operators `LessThan`, `GreaterThan`, `LessEqual`, and `GreaterEqual` were added. This is a breaking change for exhaustive matches on `Operator`.
**Usage Examples:**
evaluatorView Changes@@ -90,7 +90,7 @@
Interprets bytes according to type specifications:
-- **Byte**: Single byte values
+- **Byte**: Single byte values (signed or unsigned)
- **Short**: 16-bit integers with endianness
- **Long**: 32-bit integers with endianness
- **String**: Byte sequences with length limits
@@ -104,16 +104,18 @@
) -> Result<Value, TypeReadError>
```
+The `read_byte` function signature changed in v0.2.0 to accept three parameters (`buffer`, `offset`, and `signed`) instead of two, allowing explicit control over signed vs unsigned byte interpretation.
+
### Operator Application (`evaluator/operators.rs`)
Applies comparison operations:
- **Equal** (`=`, `==`): Exact value matching
- **NotEqual** (`!=`, `<>`): Non-matching values
-- **LessThan** (`<`): Less-than comparison (numeric or lexicographic)
-- **GreaterThan** (`>`): Greater-than comparison (numeric or lexicographic)
-- **LessEqual** (`<=`): Less-than-or-equal comparison (numeric or lexicographic)
-- **GreaterEqual** (`>=`): Greater-than-or-equal comparison (numeric or lexicographic)
+- **LessThan** (`<`): Less-than comparison (numeric or lexicographic) *(added in v0.2.0)*
+- **GreaterThan** (`>`): Greater-than comparison (numeric or lexicographic) *(added in v0.2.0)*
+- **LessEqual** (`<=`): Less-than-or-equal comparison (numeric or lexicographic) *(added in v0.2.0)*
+- **GreaterEqual** (`>=`): Greater-than-or-equal comparison (numeric or lexicographic) *(added in v0.2.0)*
- **BitwiseAnd** (`&`): Pattern matching for flags
- **BitwiseAndMask**: AND with mask then compare
@@ -125,6 +127,34 @@
left: &Value,
right: &Value,
) -> bool
+```
+
+**Example with comparison operators:**
+
+```rust
+use libmagic_rs::parser::ast::{Operator, Value};
+use libmagic_rs::evaluator::operators::apply_operator;
+
+// Less-than comparison (v0.2.0+)
+assert!(apply_operator(
+ &Operator::LessThan,
+ &Value::Uint(5),
+ &Value::Uint(10)
+));
+
+// Greater-than-or-equal comparison (v0.2.0+)
+assert!(apply_operator(
+ &Operator::GreaterEqual,
+ &Value::Uint(10),
+ &Value::Uint(10)
+));
+
+// Cross-type integer comparison (v0.2.0+)
+assert!(apply_operator(
+ &Operator::LessThan,
+ &Value::Int(-1),
+ &Value::Uint(0)
+));
```
## Evaluation Algorithm
@@ -290,6 +320,26 @@
for m in matches {
println!("Match at offset {}: {}", m.offset, m.message);
}
+```
+
+**Example with comparison operators (v0.2.0+):**
+
+```rust
+use libmagic_rs::{evaluate_rules, EvaluationConfig};
+use libmagic_rs::parser::parse_text_magic_file;
+
+// Parse magic rule with comparison operator
+let magic_content = r#"
+0 leshort <100 Small value detected
+0 leshort >=1000 Large value detected
+"#;
+let rules = parse_text_magic_file(magic_content)?;
+
+let buffer = vec![0x0A, 0x00]; // Little-endian 10
+let matches = evaluate_rules(&rules, &buffer)?;
+
+// Matches first rule (<100)
+assert_eq!(matches[0].message, "Small value detected");
```
## Implementation StatusmigrationView Changes@@ -185,6 +185,106 @@
- **GNU file output**: Text output format compatibility
- **Common use cases**: Drop-in replacement for most applications
+## Migrating from v0.1.x to v0.2.0
+
+Version 0.2.0 introduces breaking changes to support comparison operators and improve type handling. Update your code as follows:
+
+### TypeKind::Byte Variant Change
+
+The `Byte` variant changed from a unit variant to a struct variant with a `signed` field.
+
+**Before (v0.1.x):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+match type_kind {
+ TypeKind::Byte => {
+ // Handle byte type
+ }
+ _ => {}
+}
+
+// Constructing
+let byte_type = TypeKind::Byte;
+```
+
+**After (v0.2.0):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+match type_kind {
+ TypeKind::Byte { signed } => {
+ // Handle byte type, check signedness if needed
+ if signed {
+ // Handle signed byte
+ } else {
+ // Handle unsigned byte
+ }
+ }
+ _ => {}
+}
+
+// Constructing
+let signed_byte = TypeKind::Byte { signed: true };
+let unsigned_byte = TypeKind::Byte { signed: false };
+```
+
+### New Operator Variants
+
+The `Operator` enum added four comparison operators. Exhaustive matches must handle these variants.
+
+**Before (v0.1.x):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::Operator;
+
+match operator {
+ Operator::Equal => { /* ... */ }
+ Operator::NotEqual => { /* ... */ }
+ // Other existing variants
+}
+```
+
+**After (v0.2.0):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::Operator;
+
+match operator {
+ Operator::Equal => { /* ... */ }
+ Operator::NotEqual => { /* ... */ }
+ Operator::LessThan => { /* ... */ }
+ Operator::GreaterThan => { /* ... */ }
+ Operator::LessEqual => { /* ... */ }
+ Operator::GreaterEqual => { /* ... */ }
+ // Other existing variants
+}
+```
+
+### read_byte Function Signature
+
+The `libmagic_rs::evaluator::types::read_byte` function signature changed from 2 to 3 parameters.
+
+**Before (v0.1.x):**
+
+```rust,ignore
+use libmagic_rs::evaluator::types::read_byte;
+
+let value = read_byte(buffer, offset)?;
+```
+
+**After (v0.2.0):**
+
+```rust,ignore
+use libmagic_rs::evaluator::types::read_byte;
+
+// The third parameter indicates signedness
+let signed_value = read_byte(buffer, offset, true)?;
+let unsigned_value = read_byte(buffer, offset, false)?;
+```
+
## Getting Help
If you encounter migration issues:parserView Changes@@ -70,7 +70,7 @@
parse_operator("!=") // Ok(("", Operator::NotEqual))
parse_operator("<>") // Ok(("", Operator::NotEqual))
-// Comparison operators
+// Comparison operators (v0.2.0+)
parse_operator("<") // Ok(("", Operator::LessThan))
parse_operator(">") // Ok(("", Operator::GreaterThan))
parse_operator("<=") // Ok(("", Operator::LessEqual))
@@ -87,6 +87,8 @@
- ✅ Whitespace tolerance
- ✅ Invalid operator rejection with clear errors
- ✅ Eight comparison and bitwise operators supported
+
+**Note:** Comparison operators (`<`, `>`, `<=`, `>=`) were implemented in v0.2.0 via [#104](https://github.com/EvilBit-Labs/libmagic-rs/pull/104).
### Value Parsing (`parse_value`)
|
43d1bd4 to
293c953
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
47 tasks
Contributor
Merge Queue StatusRule:
This pull request spent 4 minutes 58 seconds in the queue, including 4 minutes 32 seconds running CI. Required conditions to merge
|
Contributor
🧪 CI InsightsHere's what we observed from your CI run for 293c953. 🟢 All jobs passed!But CI Insights is watching 👀 |
mergify Bot
added a commit
that referenced
this pull request
Mar 1, 2026
Update documentation for #111 _Generated by [Dosu](https://dosu.dev)_ --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: dosubot[bot] <131922026+dosubot[bot]@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2 tasks
unclesp1d3r
added a commit
that referenced
this pull request
Mar 1, 2026
## Summary - Exempt release-plz PRs (`head ~= ^release-plz-`) from the "CI must pass" merge protection - Release-plz force-pushes when updating existing PRs, and `GITHUB_TOKEN`-triggered pushes suppress workflow events, so CI never runs on the new HEAD — causing the merge protection to hang indefinitely (see PR #111) - Release-plz PRs only bump versions and changelogs; the code was already tested on main. CI still runs in the merge queue as a final safety net. ## Test plan - [ ] Verify PR #111 is no longer blocked by Mergify Merge Protections after this lands - [ ] Verify non-release-plz PRs still require CI to pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 New release
libmagic-rs: 0.1.1 -> 0.2.0 (⚠ API breaking changes)⚠
libmagic-rsbreaking changesChangelog
This PR was generated with release-plz.