Skip to content

[BUG] Key annotation generates code that tries to use to_le_bytes() for members that are structs or typedeffed strings #7

@dtjones190

Description

@dtjones190

Bug Description

Key annotation generates code that tries to use to_le_bytes() for members that are structs or typedeffed strings

IDL Input

// Minimal IDL that reproduces the issue
typedef string my_string
@extensibility(APPENDABLE)
struct HelloWorld
{
	@key
	my_string message;
};

or

// Minimal IDL that reproduces the issue
struct Inner
{
	unsigned long index;
};

@extensibility(APPENDABLE)
struct HelloWorld
{
	@key
	Inner message;
};

Command Used

hddsgen gen rust input.idl

Expected Behavior

use a different method to obtain bytes from non-primitive members

Actual Behavior

Code gen tries to use to_le_bytes()

            // FNV-1a hash of @key fields
            let mut hash: u64 = 14695981039346656037;
            const PRIME: u64 = 1099511628211;

            // Hash @key field: message
            let bytes = self.message.to_le_bytes();
            for b in bytes {
                hash ^= b as u64;
                hash = hash.wrapping_mul(PRIME);
            }

Environment

  • hdds_gen Version: 5590309
  • Backend: rust

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions