harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-7370harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-7370Implement the SeekableHttpFile struct and its associated methods to handle seekable remote files over HTTP. The struct should be able to read chunks of data from a specified URL, cache the retrieved chunks, and enable seeking functionality.
Struct Definition: Implement the SeekableHttpFile struct with the following fields:
url: String - The URL of the remote file.client: Client - An HTTP client instance for making requests.cache: HashMap<u64, Chunk> - A cache to store fetched data chunks, where the key is the index of the chunk, and the value is an array of bytes of length defined by CHUNK_SIZE.pos: u64 - Current position within the file.len: u64 - Total length of the file.Constructor: Implement the new method which initializes a SeekableHttpFile instance. It should:
create_hyper_client().Content-Length header. If the header is not present, return an appropriate error.Read Implementation: Implement the Read trait for SeekableHttpFile. The read method should:
pos.pos to reflect the number of bytes read.Seek Implementation: Implement the Seek trait for SeekableHttpFile. The seek method should:
SeekFrom enum (Start, Current, End).pos field with the new position.Cache Management: Implement a method drop_cache that clears the cache of fetched chunks.
The implementation should be placed in the /app/ directory, ensuring the struct and methods are encapsulated properly within Rust's module system. Be sure to include necessary error handling and edge case management.