Skip to content

Commit

Permalink
Formalize handle conversion
Browse files Browse the repository at this point in the history
* Changes:

- Formalize Handle conversion to pointer via Into/TryInto.
- Formalize Handle conversion from pointer via From/TryFrom.

* Motivation:

Allow bypassing `resolve` calls in situations where the handle can be
transparently resolved, for more efficient dynamic dispatch scenarios.
  • Loading branch information
matthieu-m committed Aug 14, 2023
1 parent 1e895cc commit b35b422
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ use core::{
/// - A handle is invalidated when used as an argument to the `Store::grow`, `Store::grow_zeroed`, or
/// `Store::shrink` and these methods succeed.
///
/// Handle Conversion:
///
/// - If a handle can be converted into a `NonNull<u8>`, for example via `Into`, or `TryInto`, and the handle is
/// valid, possibly dangling, then the resulting pointer must be equal to the result of `Store::resolve` and
/// obtaining this pointer must NOT invalidate any other handle.
/// - If a handle can be created from a `NonNull<u8>`, for example via `From`, or `TryFrom`, then the resulting handle
/// is a copy of the handle which resolved into the `NonNull<u8>` in the first place.
///
/// Pointer Invalidation:
///
/// - All pointers resolved by an instance of `Store` may be invalidated when dropping this instance of `Store`.
Expand Down

0 comments on commit b35b422

Please sign in to comment.