-
-
Notifications
You must be signed in to change notification settings - Fork 502
Closed
Labels
Type: EnhancementNew feature or requestNew feature or request
Description
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
- We should favor
allocandcoreinstead ofstdwhere possible and add linter rules for that. This is a simple non-breaking change and should be the first step in moving towardsno_stdsupport. - All cargo features should be additive - we should use
stdfeature instead ofno_stdand list it in every other feature that requiresstd.
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::HashMapis ano_stddrop-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
- feat(no_std): remove redundant
stdusages inratatui-core#1753 - chore(lint): add
stdinstead ofcore/alloclints toratatui-core#1759
External tasks
✅ Core Tasks Stage 1 - no_std ratatui-core
- build(deps): use kasuari instead of cassowary #1758
- refactor(no_std): Make usages of std explicit in ratatui-core. #1782
- feat(no_std)!: replace
Backend'sio::Errorusages with associatedErrortype #1778 - feat(no_std)!: option to disable layout cache for
no_stdcompatibility #1795 - feat(no_std)!: make ratatui compatible with
#![no_std]#1794 - feat(no_std)!: make
TestBackend::ErrorInfallible#1823
🏗️ Core Tasks Stage 2 - no_std ratatui-widgets & no_std backends
- feat(no_std): remove redundant
stdusages inratatui-widgets#1762 - chore(lint): add
stdinstead ofcore/alloclints toratatui-widgets#1763 - feat(no_std): make
ratatui-widgetsno_std#1779
External tasks
- feat(no_std): use
core/allocinstead ofstdwhere possible j-g00da/mousefood#39 - chore(lint): add
stdinstead ofcore/alloclints j-g00da/mousefood#45 - Depend on
ratatui-coreinstead ofratatuij-g00da/mousefood#36 - Make mousefood work with
#![no_std]j-g00da/mousefood#59
🏗️ Related bugfixes and other tasks
- feat(error)!: introduce
ratatui_core::error::Error#1817 - fix(no_std): provide
f64polyfills forno_stdcompatibility #1840 - fix(layout-cache): import
NonZeroUsizeonly whenlayout-cacheis enabled #1839 - fix(no_std): propagate
stdfeature flag to dependencies #1838 - chore: move time to dev-dependencies #1835
- chore(widgets): move crossterm to dev-dependencies #1834
- fix(no_std): final patches needed for no_std #1833
- chore(breaking-changes): add details to
no_std-related breaking changes #1828 - fix(layout): feature flag cache related types #1842
- feat(no_std): make the crate
no_std-compatible joshka/line-clipping#1 - feat(no_std): option to disable
stdkasuari#16 - Add test for
*-unknown-nonebuild #1843 - build(deps): bump
kasuariandline-clipping#1844 - feat(no_std): make
ratatui-macrosno-std #1865
valentinegb, sawicki-maciej, ed-2100, EdJoPaTo, inthehack and 14 more
Metadata
Metadata
Assignees
Labels
Type: EnhancementNew feature or requestNew feature or request