Skip to content

Tracking issue: no_std Ratatui #1750

Closed
Closed
@j-g00da

Description

@j-g00da

Previously discussed here: #1746

Problem

Currently, due to the usage of std in ratatui, its usage on embedded devices is very limited, mostly to Espressif’s MCUs based on Xtensa (nightly) and RISC-V architectures. It would be beneficial to be able to compile at least ratatui-core (and ratatui-widgets in the future) for bare-metal targets. I am convinced that it would be possible to run ratatui on many more modern MCUs such as STM32H7XX.

Solution

Convert first ratatui-core, and later ratatui-widgets to no_std implementations, add std feature flag.

Plan

Important assumptions

  1. We should favor alloc and core instead of std where possible and add linter rules for that. This is a simple non-breaking change and should be the first step in moving towards no_std support.
  2. All cargo features should be additive - we should use std feature instead of no_std and list it in every other feature that requires std.

Analysis of the current state of the codebase - ratatui-core

std usages

| 🟢 - in core | 🟡 - in alloc
 | 🔴 - requires std |

  • 🟢 std::fmt::{Write, Display, Result, Formatter, Debug}
  • 🟡 std::borrow::Cow
  • 🟢 std::str::{from_utf8, FromStr}
  • 🟢 std::ops::{Index, IndexMut, Add, Range}
  • 🟢 std::cell::{RefCell}
  • 🔴 std::collections::HashMap - hashbrown::HashMap is a no_std drop-in replacement
  • 🟢 std::iter::*
  • 🔴 std::io::Result
  • 🟢 std::num::NonZeroUsize
  • 🟡 std::rc::Rc
  • 🟢 std::cmp::{max, min}
  • 🟡 std::vec::IntoIter
  • 🟢 std::slice::{Iter, IterMut}
  • 🟢 std::error::Error

Dependencies

| ✅ - no_std | ❌ - uses std |

  • ✅ bitflags
  • ❌ cassowary - not updated since 2017, has no dependencies, probably safe to fork and do minimal changes to make it no_std-compatible, or do the same with @joshka's kasuari fork
  • ✅ compact_str

  • ✅ indoc

  • ✅ itertools
  • ✅ lru
  • ✅ strum
  • ✅ thiserror
  • ✅ unicode-segmentation
  • ✅ unicode-truncate
  • ✅ unicode-width


Optional dependencies

  • ✅ anstyle
  • ❌ document-features - only matters for docs
  • ✅ palette
  • ✅ serde

Tasks

✅ Core Tasks Stage 0 - preparations

External tasks

✅ Core Tasks Stage 1 - no_std ratatui-core

🏗️ Core Tasks Stage 2 - no_std ratatui-widgets & no_std backends

External tasks

🏗️ Related bugfixes and other tasks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions