Task: Implement the InventoryHash structure along with its serialization and deserialization functionalities, and also create a Codec for the Message enum that can encode and decode different message types, specifically Inv and GetData.
Requirements:
InventoryHash Structure:
Implement the InventoryHash structure which must include the necessary fields to represent an inventory hash.
Implement the ZcashSerialize trait for InventoryHash to handle serialization into a byte vector. Ensure that the serialization does not produce output larger than MAX_INVENTORY_HASH_BYTES (70 bytes).
Implement the ZcashDeserializeInto trait for InventoryHash to allow deserialization from a byte vector. The deserialization should validate the input bytes and produce an error with the message "invalid inventory code" if the inventory code is incorrect or returns an appropriate error for insufficient bytes.
Codec for Message:
Implement the Codec struct that can encode and decode Message variants (Inv and GetData).
Ensure the Codec can be built using a builder pattern.
Implement the encode method to serialize the Message into a BytesMut instance.
Implement the decode method to deserialize from a BytesMut instance back into a Message. The decoding should return Ok(Some(message)) if successful.
Testing Compliance:
Ensure that the implementations pass the provided tests by running the test suite and addressing any failing cases, particularly focusing on serialization/deserialization for InventoryHash and encoding/decoding for Message.
File Locations:
The code should be placed in the /app/ directory to be integrated within the existing application structure.