ustyle 0.1.1

A text-styling library for Rust `no_std` embedded targets.
Documentation
  • Coverage
  • 100%
    100 out of 100 items documented0 out of 47 items with examples
  • Size
  • Source code size: 28.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 638.46 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • DraftedDev

μStyle || Micro Style

Crates.io Version License docs.rs

A text-styling library for Rust no_std embedded targets.

Motivation

After I tried creating a no_std embedded ANSI library, I noticed serious flaws in the ANSI format and decided to create my own format:

μStyle (pronounced "Micro Style") is a ASCII-compatible text-styling format and library to style text with colors and attributes. The format is similar to ANSI, but uses way less bytes and is more compact.

It allows for fully heap-less styling of text without much stack-overhead.

Why μStyle?

  • Styling only adds 5 bytes of overhead.
  • Very predictable behaviour.
  • Fast parsing and low overhead.
  • Very lightweight.
  • Less complex than ANSI.

Comparison with ANSI

ANSI and μStyle are both ASCII-compatible text-styling formats.

While ANSI uses tags to style text, μStyle uses a fixed descriptor format which only adds 5 bytes of overhead while an ANSI tag can add up to 19 bytes of overhead.

Keep in mind that you need multiple ANSI tags for fully styled strings.

Feature μStyle ANSI
Byte overhead always 5 bytes up to 19 bytes per tag (possibility of multiple tags, so basically unlimited overhead possible)
Colors only 35 colors (plus None color) built-in, index or RGB (basically all the colors)
Attributes bitflag-based and constant sized many with separate codes, adding extra style size

Limitations

μStyle does have some limitations:

  • Only 35 colors (plus None color) are supported.
  • It's not as expressive as ANSI.
  • It's less feature rich than ANSI.
  • Delimiters are fixed and cannot be escaped (which is however mostly fine, as they are special characters and not used in human-readable text anyway).