Expand description
Segment-level borrow registry for fine-grained access control.
The account-level BorrowRegistry prevents
aliasing across entire accounts. This module adds segment-level
conflict detection: two borrows of the same account are allowed when
their byte ranges don’t overlap, or when both are read-only.
§Conflict Rules
| Existing | New | Overlapping? | Allowed |
|---|---|---|---|
| Read | Read | yes | ✅ |
| Read | Write | yes | ❌ |
| Write | Read | yes | ❌ |
| Write | Write | yes | ❌ |
| any | any | no | ✅ |
§Zero-Cost Design
- Fixed-capacity array (no heap)
- Inline conflict checks
- Deterministic iteration (bounded loop)
Structs§
- Segment
Borrow - A single active segment borrow.
- Segment
Borrow Guard - RAII guard that releases a segment borrow when dropped.
- Segment
Borrow Registry - Instruction-scoped segment borrow registry.
Enums§
- Access
Kind - Read or write access intent for a segment borrow.
Constants§
- MAX_
SEGMENT_ BORROWS - Maximum simultaneous segment borrows per instruction.