rusturnate [![crates.io](https://img.shields.io/crates/v/rusturnate.svg)](https://crates.io/crates/rusturnate) [![documentation](https://docs.rs/rusturnate/badge.svg)](https://docs.rs/rusturnate) [![pipeline status](https://gitlab.com/in2vd-open/rusturnate/badges/main/pipeline.svg)]( https://gitlab.com/in2vd-open/rusturnate/-/commits/main) ## Overview `rusturnate` introduces a cell-like object called a `Rusturn`, which may hold an arbitrary type. It can be shared across thread or future boundaries using `Arc` or `static`. ## The ``Editor`` (``MutexGuard``) Similar to `std::sync::Mutex`, a `Rusturn` allows only one thread or future to access its contents at a time by acquiring an `Editor` (similar to a `MutexGuard`). There can only be one editor instance accessing a `Rusturn` object at any given moment. To finish editing the editor must either be dropped or `.done()` must be invoked on it. Subsequently, other threads can acquire a new instance of an editor. If a panic occurs while holding an editor it gets marked as poisoned. Despite this, access is still possible. However, you will need to handle the resulting `PoisonError` and update the editorĀ“s value to clear its poisoned state. `auto-poisoning` only works if the `std` feature is enabled. Otherwise, you can do manual poisoning by activating the `manual_poisoning` or `anytime_poisoning` feature. ## Manual poisoning ``TODO`` ## The ``Access`` object ``TODO`` ## Awaiting results ``TODO`` ## Feature flags ``TODO`` ## Use of ``unsafe`` ``TODO`` ## Allocation details This crate itself does not perform any heap allocations. However, if the `suspending_with_timeout` feature is enabled, it utilizes the [futures-timer](https://crates.io/crates/futures-timer) crate, which does perform heap allocations. `futures-timer` is only used for suspending execution in an `async` context with a timeout. ## Roadmap - [x] ``Rusturn``/``Editor`` implementation - [x] ``sync/async`` awaiting/queuing - [x] ``sync/async`` timeouts - [x] auto/manual poisoning - [ ] full ``README.md`` explanation - [ ] clear documentation for exposed methods - [ ] documentation for internal methods - [ ] explicit edge case tests - [ ] more debug assertions ## License Licensed under either of Apache License, Version 2.0 or MIT license.