Tag rust in blog posts
Determining if a File is a PDF in Rust
In my work generating BI (Business Intelligence) reports as PDFs with Apache FOP (the Java XSL-FO to PDF engine), I often need to verify that an output file is actually a PDF before further processing. A reliable way to do this is to inspect the file’s “magic bytes” – the fixed signature at the start of the file. Magic bytes (also called file signatures or magic numbers) are small sequences of bytes placed at the beginning of a file to identify its format. Because these signatures are defined by the file format itself and deliberately chosen to be unique, checking them is a fast and reliable way to recognize a PDF (or any file type) regardless of its extension.
Converting Excel Column Names to Numbers in Rust
When working with Excel files programmatically, converting column names (like “A”, “B”, “C”, …, “Z”, “AA”, “AB”, etc.) to their corresponding numeric values (0, 1, 2, …, 25, 26, 27, etc.) is a common task. Rust, with its performance, safety, and expressiveness, is an excellent choice for implementing such functionality.
Tag rust in projects
LRU Memory Cache Library in Rust
in-memory-cache is a straightforward, yet powerful crate that delivers an easy-to-use in-memory cache solution with a Least Recently Used (LRU) eviction policy. This crate facilitates the efficient storage of key-value pairs, providing automatic eviction of the least recently accessed entries when the cache reaches its predefined capacity.