Posts
All the articles I have published.
-
Using Bit Masks for Conditional Checks in Rust
Published date:Exploring how to use bit masks (or bit flags) for efficient conditional checks in Rust, particularly useful for managing multiple state flags with high performance and low memory usage.
-
JNI in Rust
Published date:Exploring how to use JNI (Java Native Interface) to enable interaction between Java/JVM platform languages and Rust, including type mappings and implementation details.
-
Building a Handwriting Input Method from Scratch: Conclusion
Published date:Wrapping up the series on building a handwriting input method from scratch, discussing the complete implementation, challenges faced, and lessons learned throughout the project.
-
Building a Handwriting Input Method from Scratch: WASM Deployment
Published date:Deploying the trained handwriting recognition model to WebAssembly using Rust, enabling efficient client-side recognition in web browsers.
-
Building a Handwriting Input Method from Scratch: Model Inference
Published date:Implementation of handwriting recognition model inference using Rust Candle, focusing on optimizing performance and efficiency for real-time applications.
-
Building a Handwriting Input Method from Scratch: Model Training
Published date:Detailed guide on processing the CASIA-HWDB dataset and training a handwriting recognition model for Chinese characters using PyTorch, including dataset preprocessing and model implementation.
-
Building a Handwriting Input Method from Scratch: Preparation
Published date:Introduction to building a handwriting input method for Chinese characters from scratch, covering preparation steps, dataset selection, and technical approach using PyTorch for training, Rust Candle for inference, and WASM for deployment.
-
How to Access a Zip File as Conveniently as a Folder?
Published date:This article explains how to use FUSE to access a zip file as if it were a folder.
-
“Unsafe” Rust: Common Pitfalls in Rust
Published date:This article summarizes common security pitfalls in Rust development, including numeric conversions, integer overflows, array boundary access, oversized array handling, misuse of `unsafe`, time-of-check to time-of-use (TOCTOU) attacks, FFI risks, and circular references. By correctly using type-safe methods, limiting resource sizes, reducing the scope of `unsafe`, combining atomic operations, and managing memory, these issues can be effectively avoided.
-
Conversion of HEIF/HEIC Format Images to Other Image Formats
Published date:This article introduces methods for converting HEIF/HEIC format images, which suffer from poor compatibility due to patent issues related to HEVC technology. In Rust, HEIF images can be decoded using `libheif-rs` and converted to other formats via the `image` crate. On the frontend, similar functionality can be achieved with `heic-convert`, focusing on constructing buffer data that meets requirements for format conversion.
-
Rust's 'Uncommon but Super Useful' Syntaxes: How Many Do You Know?
Published date:This article introduces some uncommon but practical syntax features in Rust, including unions (`union`), slice pattern matching, raw pointer operations, inline assembly (`asm!`), extern blocks, loop return values, the `@` in match patterns, labeled loop control, never type (`!`), `#[repr]` attributes, and diverse macro invocation methods. These features can significantly enhance development efficiency and code flexibility in specific scenarios.
-
Rust Implementation of RMBG Inference
Published date:This article introduces how to implement RMBG (Remove Image Background) inference using Rust. By loading an ONNX model, it preprocesses the input image (resize, normalization), completes the model inference to generate a mask image, and uses the mask to remove the background or blend transparency. Finally, it optimizes the mask denormalization algorithm to improve background purity, suitable for use in fields like posters, games, etc.