#entities #format #cpulist

cpulist

Parse and emit the Linux 'cpulist' data format used to list processors, memory regions and similar entities

9 releases

Uses new Rust 2024

new 0.2.0 Apr 11, 2025
0.1.2 Apr 6, 2025
0.1.1 Mar 31, 2025
0.0.2 Mar 26, 2025

#1021 in Parser implementations

Download history 240/week @ 2025-03-05 243/week @ 2025-03-12 43/week @ 2025-03-19 418/week @ 2025-03-26 162/week @ 2025-04-02

884 downloads per month
Used in 5 crates (2 directly)

MIT license

27KB
242 lines

Utilities for parsing and emitting strings in the the cpulist format often used by Linux utilities that work with processor IDs, memory region IDs and similar numeric hardware identifiers.

Example cpulist string: 0-9,32-35,40

This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.

Format

The value is a comma-separated list of zero or more integers or integer ranges, where each item is either:

  • a single integer (e.g. 1)
  • a range of integers (e.g. 2-4)
  • a range of integers with a stride (step size) operator (e.g. 5-9:2 which is equivalent to 5,7,9)

Whitespace or extra characters are not allowed anywhere in the string.

The identifiers in the list are of size u32.

Example

Basic conversion from/to strings:

The stride operator is also supported for parsing:


Utilities for parsing and emitting strings in the the cpulist format often used by Linux utilities that work with processor IDs, memory region IDs and similar numeric hardware identifiers.

Example cpulist string: 0,1,2-4,5-9:2,6-10:2

More details in the crate documentation.

This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.

Dependencies

~4–16MB
~148K SLoC