chore: release v0.5.0#163
Merged
Merged
Conversation
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Do not merge outdated PRsWonderful, this rule succeeded.Make sure PRs are within 10 commits of the base branch before merging
|
Contributor
|
Documentation Updates 3 document(s) were updated by changes in this PR: api-referenceView Changes@@ -226,7 +226,9 @@
| `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 |
+| `Float { endian }` | 32-bit IEEE 754 floating-point (added in v0.5.0) |
+| `Double { endian }` | 64-bit IEEE 754 double-precision floating-point (added in v0.5.0) |
+| `String { max_length }` | String data (discriminant changed from 4 to 6 in v0.5.0) |
### Operator
@@ -285,12 +287,15 @@
use libmagic_rs::Value;
```
-| Variant | Description |
-| ---------------- | ---------------- |
-| `Uint(u64)` | Unsigned integer |
-| `Int(i64)` | Signed integer |
-| `Bytes(Vec<u8>)` | Byte sequence |
-| `String(String)` | String value |
+| Variant | Description |
+| ---------------- | ------------------------------------------------------- |
+| `Uint(u64)` | Unsigned integer |
+| `Int(i64)` | Signed integer |
+| `Float(f64)` | Floating-point value (added in v0.5.0) |
+| `Bytes(Vec<u8>)` | Byte sequence |
+| `String(String)` | String value |
+
+The `Value` enum derives `PartialEq` but no longer derives `Eq` (removed in v0.5.0 to support floating-point values).
### Endianness
@@ -406,13 +411,14 @@
use libmagic_rs::evaluator::MatchResult;
```
-| Field | Type | Description |
-| ------------ | -------- | ----------------- |
-| `message` | `String` | Match description |
-| `offset` | `usize` | Match offset |
-| `level` | `u32` | Rule level |
-| `value` | `Value` | Matched value |
-| `confidence` | `f64` | Confidence score |
+| Field | Type | Description |
+| ------------ | -------- | ------------------------------------- |
+| `message` | `String` | Match description |
+| `offset` | `usize` | Match offset |
+| `level` | `u32` | Rule level |
+| `value` | `Value` | Matched value |
+| `type_kind` | `TypeKind` | Type used to read value (added in v0.5.0) |
+| `confidence` | `f64` | Confidence score |
## Output Module
@@ -507,7 +513,15 @@
- **Minimum Rust Version**: 1.85
- **Edition**: 2024
- **License**: Apache-2.0
-- **Current Version**: 0.2.1
+- **Current Version**: 0.5.0
+
+### Breaking Changes in v0.5.0
+
+- `TypeKind` enum: Added `Float { endian }` and `Double { endian }` variants for IEEE 754 floating-point support
+- `TypeKind::String` discriminant changed from 4 to 6 to accommodate new float types
+- `Value` enum: Added `Float(f64)` variant for floating-point values
+- `Value` enum: No longer derives `Eq` trait (only `PartialEq` is available due to floating-point values)
+- `RuleMatch` struct: Added `type_kind: TypeKind` field to indicate the type used for matching
### Breaking Changes in v0.2.0
GETTING_STARTEDView Changes@@ -21,10 +21,12 @@
```toml
[dependencies]
-libmagic-rs = "0.4.3"
-```
-
-**Note:** Version 0.4.0 introduces breaking changes. If upgrading from 0.3.x, the `Operator` enum gained three new variants (`BitwiseXor`, `BitwiseNot`, `AnyValue`) for bitwise and any-value operations. Exhaustive pattern matching on `Operator` requires updates.
+libmagic-rs = "0.5.0"
+```
+
+**Note:** Version 0.5.0 introduces breaking changes. If upgrading from 0.4.x, the `RuleMatch` struct has a new `type_kind` field that must be included in struct literals, the `Value` enum no longer derives the `Eq` trait (affecting comparison operations), and the `TypeKind` enum gained two new variants (`Float`, `Double`) for floating-point types with endian variants, causing the `TypeKind::String` variant discriminant to change from 4 to 6. Exhaustive pattern matching on `TypeKind` and struct literals for `RuleMatch` require updates.
+
+Version 0.4.0 introduces breaking changes. If upgrading from 0.3.x, the `Operator` enum gained three new variants (`BitwiseXor`, `BitwiseNot`, `AnyValue`) for bitwise and any-value operations. Exhaustive pattern matching on `Operator` requires updates.
Version 0.3.0 introduced breaking changes from 0.2.x: a new `TypeKind::Quad` enum variant was added for 64-bit quad integer types with endian variants, `TypeKind::String` variant discriminant changed from 3 to 4, and `evaluator::MatchResult` was renamed to `evaluator::RuleMatch` to resolve a naming collision with `output::MatchResult`. The public re-export is `RuleMatch`. Exhaustive pattern matching on `TypeKind` requires updates.
@@ -67,7 +69,7 @@
```toml
[dependencies]
-libmagic-rs = "0.4.3"
+libmagic-rs = "0.5.0"
```
#### Step 3: Write CodemigrationView Changes@@ -436,6 +436,167 @@
These operators enable fuller support for libmagic file format specifications and extend bitwise operation capabilities.
+## Migrating from v0.4.x to v0.5.0
+
+Version 0.5.0 adds support for float and double types with endian variants, introducing breaking changes to core types. Update your code as follows:
+
+### RuleMatch Struct Field Addition
+
+The `RuleMatch` struct gained a new `type_kind: TypeKind` field. Code constructing `RuleMatch` using struct literals must include this field.
+
+**Before (v0.4.x):**
+
+```rust,ignore
+use libmagic_rs::evaluator::RuleMatch;
+use libmagic_rs::parser::ast::Value;
+
+let match_result = RuleMatch {
+ message: "ELF executable".to_string(),
+ offset: 0,
+ level: 0,
+ value: Value::Uint(0x7f),
+ confidence: RuleMatch::calculate_confidence(0),
+};
+```
+
+**After (v0.5.0):**
+
+```rust,ignore
+use libmagic_rs::evaluator::RuleMatch;
+use libmagic_rs::parser::ast::{Value, TypeKind};
+
+let match_result = RuleMatch {
+ message: "ELF executable".to_string(),
+ offset: 0,
+ level: 0,
+ value: Value::Uint(0x7f),
+ confidence: RuleMatch::calculate_confidence(0),
+ type_kind: TypeKind::Byte { signed: false },
+};
+```
+
+### Value Enum Changes
+
+The `Value` enum added a new `Float(f32)` variant and no longer derives the `Eq` trait (it still has `PartialEq`).
+
+**New Variant:**
+
+```rust,ignore
+use libmagic_rs::parser::ast::Value;
+
+let float_value = Value::Float(3.14159);
+```
+
+**Removed Eq Trait:**
+
+Code using `Eq` trait bounds must be updated to use `PartialEq` instead. Exact equality comparisons on floating-point values should use approximate comparison techniques.
+
+**Before (v0.4.x):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::Value;
+use std::collections::HashSet;
+
+// This compiles because Value derives Eq and Hash
+let mut value_set: HashSet<Value> = HashSet::new();
+value_set.insert(Value::Uint(42));
+```
+
+**After (v0.5.0):**
+
+```rust,ignore
+// HashSet requires Eq, so this no longer compiles
+// Use Vec or another collection that only requires PartialEq
+
+use libmagic_rs::parser::ast::Value;
+
+let mut values: Vec<Value> = Vec::new();
+values.push(Value::Uint(42));
+values.push(Value::Float(3.14));
+
+// For equality checks, use PartialEq
+if values[0] == Value::Uint(42) {
+ // Handle match
+}
+```
+
+### TypeKind Enum Extensions
+
+The `TypeKind` enum added two new variants: `Float` and `Double` (each with multiple endian variants). This changes the discriminant value of the `String` variant from 4 to 6.
+
+**New Variants:**
+
+Exhaustive match statements must handle the new float and double type variants.
+
+**Before (v0.4.x):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+match type_kind {
+ TypeKind::Byte { signed } => { /* ... */ }
+ TypeKind::Short { endian, signed } => { /* ... */ }
+ TypeKind::Long { endian, signed } => { /* ... */ }
+ TypeKind::Quad { endian, signed } => { /* ... */ }
+ TypeKind::String { max_length } => { /* ... */ }
+}
+```
+
+**After (v0.5.0):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+match type_kind {
+ TypeKind::Byte { signed } => { /* ... */ }
+ TypeKind::Short { endian, signed } => { /* ... */ }
+ TypeKind::Long { endian, signed } => { /* ... */ }
+ TypeKind::Quad { endian, signed } => { /* ... */ }
+ TypeKind::Float { endian } => {
+ // Handle 32-bit float type
+ }
+ TypeKind::Double { endian } => {
+ // Handle 64-bit double type
+ }
+ TypeKind::String { max_length } => { /* ... */ }
+}
+```
+
+**Alternative:** Use a wildcard pattern if you do not need to handle all types explicitly:
+
+```rust,ignore
+match type_kind {
+ TypeKind::Byte { signed } => { /* specific handling */ }
+ _ => { /* generic handling */ }
+}
+```
+
+**Discriminant Changes:**
+
+The `String` variant discriminant changed from 4 to 6. Code using numeric casts on `TypeKind` variants must be updated.
+
+**Before (v0.4.x):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+let type_kind = TypeKind::String { max_length: None };
+let discriminant = type_kind as isize; // Returns 4
+```
+
+**After (v0.5.0):**
+
+```rust,ignore
+use libmagic_rs::parser::ast::TypeKind;
+
+let type_kind = TypeKind::String { max_length: None };
+let discriminant = type_kind as isize; // Returns 6
+```
+
+**Recommendation:** Avoid relying on enum discriminant values. Use pattern matching or the `std::mem::discriminant` function instead.
+
+These changes enable float and double type support in magic file parsing, expanding the range of file formats and data types the library can identify.
+
## Getting Help
If you encounter migration issues: |
mergify Bot
pushed a commit
that referenced
this pull request
Mar 7, 2026
…164) Update documentation for #163 Updated migration guide and API reference to clarify v0.5.0 breaking changes, including Float(f64) value type, TypeKind float/double variants, RuleMatch type_kind field, and Eq trait removal from Value enum. Enhanced documentation accuracy in GETTING_STARTED and migration sections for better clarity on version upgrade paths and API compatibility. _Generated by [Dosu](https://dosu.dev)_ Co-authored-by: dosubot[bot] <131922026+dosubot[bot]@users.noreply.github.com>
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.4.3 -> 0.5.0 (⚠ API breaking changes)⚠
libmagic-rsbreaking changesChangelog
This PR was generated with release-plz.