Skip to content

chore: release v0.5.0#163

Merged
mergify[bot] merged 1 commit into
mainfrom
release-plz-2026-03-07T05-13-00Z
Mar 7, 2026
Merged

chore: release v0.5.0#163
mergify[bot] merged 1 commit into
mainfrom
release-plz-2026-03-07T05-13-00Z

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Mar 7, 2026

🤖 New release

  • libmagic-rs: 0.4.3 -> 0.5.0 (⚠ API breaking changes)

libmagic-rs breaking changes

--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field RuleMatch.type_kind in /tmp/.tmpUBXECi/libmagic-rs/src/evaluator/mod.rs:220
  field RuleMatch.type_kind in /tmp/.tmpUBXECi/libmagic-rs/src/evaluator/mod.rs:220

--- failure derive_trait_impl_removed: built-in derived trait no longer implemented ---

Description:
A public type has stopped deriving one or more traits. This can break downstream code that depends on those types implementing those traits.
        ref: https://doc.rust-lang.org/reference/attributes/derive.html#derive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/derive_trait_impl_removed.ron

Failed in:
  type Value no longer derives Eq, in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:309
  type Value no longer derives Eq, in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:309
  type Value no longer derives Eq, in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:309

--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
  variant TypeKind::String 4 -> 6 in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:147
  variant TypeKind::String 4 -> 6 in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:147
  variant TypeKind::String 4 -> 6 in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:147

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_variant_added.ron

Failed in:
  variant TypeKind:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:128
  variant TypeKind:Double in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:142
  variant TypeKind:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:128
  variant TypeKind:Double in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:142
  variant TypeKind:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:128
  variant TypeKind:Double in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:142
  variant Value:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:324
  variant Value:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:324
  variant Value:Float in /tmp/.tmpUBXECi/libmagic-rs/src/parser/ast.rs:324
Changelog

[0.5.0] - 2026-03-07

Features

  • parser: Implement float and double types with endian variants (#162)


This PR was generated with release-plz.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 7, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 7, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Do not merge outdated PRs

Wonderful, this rule succeeded.

Make sure PRs are within 10 commits of the base branch before merging

  • #commits-behind <= 3

@dosubot dosubot Bot added parser Magic file parsing components and grammar rust Rust language features and idioms labels Mar 7, 2026
@mergify mergify Bot merged commit 5cbfa7a into main Mar 7, 2026
6 checks passed
@mergify mergify Bot deleted the release-plz-2026-03-07T05-13-00Z branch March 7, 2026 05:14
@dosubot
Copy link
Copy Markdown
Contributor

dosubot Bot commented Mar 7, 2026

Documentation Updates

3 document(s) were updated by changes in this PR:

api-reference
View 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_STARTED
View 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 Code
migration
View 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:

How did I do? Any feedback?  Join Discord

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parser Magic file parsing components and grammar rust Rust language features and idioms size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants