| Crates.io | cordyceps |
| lib.rs | cordyceps |
| version | 0.3.4 |
| created_at | 2022-06-04 18:53:32.644466+00 |
| updated_at | 2025-05-21 17:07:53.472458+00 |
| description | Mycelium intrusive data structures. |
| homepage | https://mycelium.elizas.website |
| repository | https://github.com/hawkw/mycelium |
| max_upload_size | |
| id | 599849 |
| size | 292,734 |
🍄 the Mycelium intrusive data structures library.
This library provides a collection of intrusive data structures originally implemented for the Mycelium operating system. Currently, it provides an intrusive doubly-linked list and an intrusive, lock-free MPSC queue.
Note
This is a hobby project. I'm working on it in my spare time, for my own personal use. I'm very happy to share it with the broader Rust community, and contributions and bug reports are always welcome. However, please remember that I'm working on this library for fun, and if it stops being fun...well, you get the idea.
Anyway, feel free to use and enjoy this crate, and to contribute back as much as you want to!
Intrusive data structures are node-based data structures where the node data (pointers to other nodes and, potentially, any associated metadata) are stored within the values that are contained by the data structure, rather than owning those values.
statics), they can be added to intrusive data structures
without allocating at all. This makes intrusive data structures useful in
code that cannot allocate — for example, we might use intrusive lists of
memory regions to implement a heap allocator.struct is to be stored in an intrusive
collection, it will need to store a Links struct for that structure as a
field, and implement the Linked trait to allow the intrusive data structure
to access its Links.Linked type may not be added to multiple intrusive
data structures of the same type. This can sometimes be worked around with
multiple wrapper types. An object may be a member of multiple intrusive data
structures of different types.unsafe code. The Linked trait
is unsafe to implement, as it requires that types implementing Linked
uphold additional invariants. In particular, members of intrusive collections
must be pinned in memory; they may not move (or be dropped) while linked
into an intrusive collection.Rudimentary support for targets without CAS (Compare and Swap) atomics, such as
Cortex-M0+/thumbv6m-none-eabi, is provided, however not all structures and
features may be available.
CAS atomic support is automatically detected with cfg(target_has_atomic = "ptr"),
which notes that a platform has support for both load/store operations as well
as support for CAS atomics.
No crate-level features are necessary to enable/disable structures that require CAS atomics.
In keeping with Mycelium's fungal naming theme, Cordyceps is a genus of ascomycete fungi that's (in)famous for its intrusive behavior.
The following features are available (this list is incomplete; you can help by expanding it.)
| Feature | Default | Explanation |
|---|---|---|
no-cache-pad |
false |
Inhibits cache padding for the CachePadded struct used for many linked list pointers. When this feature is NOT enabled, the size will be determined based on target platform. |
alloc |
false |
Enables liballoc dependency and features that depend on liballoc. |
std |
false |
Enables libstd dependency and features that depend on the Rust standard library. Implies alloc. |