Runtime Ownership for Rust
This library implements the concept of dynamic ownership by introducing three core types: Owner, Viewer, and Holder. These types serve distinct roles in managing shared data, enabling flexible and safe ownership control at runtime.
Type Descriptions
-
Owner:
Represents exclusive ownership of shared data. TheOwnercan view, modify, or destroy the shared data. Only oneOwnermay exist at a time for a given piece of data, and it cannot coexist with anotherOwnerorViewer. However, it may coexist with one or moreHolderinstances. -
Viewer:
Represents shared, read-only access to the data. AViewercan view the shared data but cannot modify it. MultipleViewerinstances can coexist with each other, and they may also exist alongsideHolderinstances. -
Holder:
Holds a reference to shared data without the ability to directly view or modify it. AHoldercan be downgraded from anOwnerorViewer, and later upgraded to either aVieweror anOwneras needed.
Example
use Holder;
use Owner;
use Viewer;
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.