Crates.io | buup |
lib.rs | buup |
version | |
source | src |
created_at | 2025-04-27 09:12:20.173524+00 |
updated_at | 2025-05-08 01:30:18.984195+00 |
description | Core transformation library with zero dependencies |
homepage | https://buup.io |
repository | https://github.com/benletchford/buup |
max_upload_size | |
id | 1650956 |
Cargo.toml error: | TOML parse error at line 25, column 1 | 25 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Buup is a versatile text transformation toolkit that provides a dependency-free core library and CLI for common text manipulations like encoding/decoding, formatting, cryptography, (coming soon compression/decompression), and more written in pure dependency-free Rust.
It is designed to be a simple, lightweight, open, secure, provably fast and easy to integrate.
Drop-in replacement for all of those dodgy online text transformation tools you've ever used in the past except the batteries are included (and they are all in pure Rust).
It includes a web application which is of course written in pure Rust (WASM via Dioxus) as a separate workspace member.
buup
library and its CLI implement all transformations without external dependenciesTransform
traitBuup offers three distinct ways to transform your text:
A modern, responsive web application for interactive text transformations proudly built with Dioxus.
Dark Mode | Light Mode |
---|---|
![]() |
![]() |
From source:
# Serve the web UI (requires Dioxus CLI)
cd buup_web
dx serve
Build for production:
dx build
Zero-dependency CLI for quick transformations in your terminal workflows.
# Installation
cargo binstall buup # or cargo install buup
# List available transformers
buup list
# Examples
buup base64encode "Hello, world!" # Encode text directly
buup urldecode -i encoded.txt # Decode from file
echo "Hello" | buup hexencode # Pipe from stdin
Integrate Buup's transformers directly into your Rust applications.
# Add to your project
cargo add buup
use buup::{transformer_from_id, Transform, Base64Encode};
// Option 1: Use a specific transformer struct
let encoded = Base64Encode.transform("Hello, Library!").unwrap();
println!("{}", encoded); // SGVsbG8sIExpYnJhcnkh
// Option 2: Look up a transformer by its ID
let transformer = transformer_from_id("base64decode").unwrap();
let decoded = transformer.transform(&encoded).unwrap();
println!("{}", decoded); // Hello, Library!
The following transformers are currently available in Buup:
Available transformers:
ENCODERS:
ascii_to_hex - Convert ASCII characters to their hexadecimal representation.
base64encode - Encode text to Base64 format
bin_to_hex - Convert binary numbers to hexadecimal.
binaryencode - Encode text into its binary representation (space-separated bytes).
dec_to_bin - Convert decimal numbers to binary.
dec_to_hex - Convert decimal numbers to hexadecimal.
hex_to_bin - Converts hexadecimal input to its binary representation (Base64 encoded).
hexencode - Encode text to hexadecimal representation
htmlencode - Encodes special HTML characters into their entity representation (e.g., < to <).
morseencode - Encode text to Morse code
rot13 - Applies the ROT13 substitution cipher to the input text.
urlencode - Encode text for use in URLs
DECODERS:
base64decode - Decode Base64 text to plain text
bin_to_dec - Convert binary numbers to decimal.
binarydecode - Decode space-separated binary representation back to text.
hex_to_ascii - Decodes a hexadecimal string into its ASCII representation.
hex_to_dec - Converts hexadecimal numbers to their decimal representation.
hexdecode - Decodes a hexadecimal string into its original bytes, then interprets as UTF-8.
htmldecode - Decodes HTML entities (e.g., <) back into characters (<).
jwtdecode - Decodes a JSON Web Token (JWT) without verifying the signature.
morsedecode - Decodes Morse code into text.
urldecode - Decode URL-encoded text
FORMATTERS:
jsonformatter - Formats (pretty-prints) a JSON string.
jsonminifier - Minifies a JSON string, removing unnecessary whitespace.
linenumberadder - Adds line numbers to the beginning of each line.
linenumberremover - Removes line numbers (and optional delimiters) from the beginning of each line.
CRYPTOGRAPHY:
md5hash - Calculates the MD5 hash of the input string.
sha1hash - Computes the SHA-1 hash of the input text (Warning: SHA-1 is cryptographically weak)
sha256hash - Computes the SHA-256 hash of the input text
uuid5_generate - Generates a version 5 UUID based on namespace and name using SHA-1. Input format: "namespace|name". Namespace can be a UUID or one of: dns, url, oid, x500.
COMPRESSION:
deflatecompress - Compresses input using the DEFLATE algorithm (RFC 1951) and encodes the output as Base64.
deflatedecompress - Decompresses DEFLATE input (RFC 1951). Expects Base64 input.
gzipcompress - Compresses input using Gzip (RFC 1952) and encodes the output as Base64.
gzipdecompress - Decompresses Gzip formatted input (RFC 1952). Expects Base64 input.
OTHERS:
cameltosnake - Converts camelCase or PascalCase to snake_case
csvtojson - Converts CSV data to JSON format
jsontocsv - Converts a JSON array of objects into CSV format.
linesorter - Sorts lines alphabetically.
slugify - Converts text into a URL-friendly slug (lowercase, dashes, removes special chars)
snaketocamel - Converts snake_case to camelCase
text_stats - Calculates basic text statistics (lines, words, chars, sentences)
textreverse - Reverses the input text
uniquelines - Removes duplicate lines, preserving the order of first occurrence.
urlparser - Parses a URL into its components (scheme, authority, path, query, fragment)
uuid_generate - Generates a version 4 UUID. Input is ignored. WARNING: Uses a non-cryptographically secure PRNG.
whitespaceremover - Removes all whitespace (spaces, tabs, newlines) from the input text.
EXAMPLES:
buup base64encode "Hello, world!" # Encode text directly
buup urldecode -i encoded.txt # Decode from file
echo "Hello" | buup hexencode # Pipe from stdin
buup list
cargo run --bin update_readme
Contributions are welcome! When adding new transformers or modifying code, please ensure:
buup
libraryTransformError
cargo test --workspace
and cargo clippy --workspace -- -D warnings
Basic Structure
To create a custom transformer:
Transform
traitlib.rs
Step 1: Example Implementation
Here's a simple example of a custom transformer that reverses text:
use buup::{Transform, TransformError, TransformerCategory};
/// Text Reverse transformer
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct TextReverse;
impl Transform for TextReverse {
fn name(&self) -> &'static str {
"Text Reverse"
}
fn id(&self) -> &'static str {
"textreverse"
}
fn category(&self) -> TransformerCategory {
TransformerCategory::Other
}
fn description(&self) -> &'static str {
"Reverses the input text"
}
fn transform(&self, input: &str) -> Result<String, TransformError> {
Ok(input.chars().rev().collect())
}
fn default_test_input(&self) -> &'static str {
"Example Input"
}
}
Step 2: Add to Registry
In lib.rs
, add your transformer to the register_builtin_transformers
function:
fn register_builtin_transformers() -> Registry {
let mut registry = Registry {
transformers: HashMap::new(),
};
// ... existing registrations ...
// Import your new transformer struct
use crate::transformers::my_transformer::MyNewTransformer;
// Add your new transformer instance
registry.transformers.insert(MyNewTransformer.id(), &MyNewTransformer);
registry
}
Step 3: Export Your Transformer (Optional)
If your transformer will be used directly, add it to the exports in transformers/mod.rs
:
// src/transformers/mod.rs
mod base64_decode;
// ... other mods ...
mod my_transformer; // Your new module
pub use base64_decode::Base64Decode;
// ... other uses ...
pub use my_transformer::MyNewTransformer; // Your new transformer
Step 4: Add Inverse Support (Optional)
If your transformer has an inverse operation, update the inverse_transformer
function in lib.rs
:
pub fn inverse_transformer(t: &dyn Transform) -> Option<&'static dyn Transform> {
match t.id() {
// ... existing matches ...
"my_encoder" => transformer_from_id("my_decoder").ok(), // Your transformer pair
"my_decoder" => transformer_from_id("my_encoder").ok(), // Your transformer pair
_ => None,
}
}
Tips for Creating Good Transformers