Skip to main content

Module segment_borrow

Module segment_borrow 

Source
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

ExistingNewOverlapping?Allowed
ReadReadyes
ReadWriteyes
WriteReadyes
WriteWriteyes
anyanyno

§Zero-Cost Design

  • Fixed-capacity array (no heap)
  • Inline conflict checks
  • Deterministic iteration (bounded loop)

Structs§

SegmentBorrow
A single active segment borrow.
SegmentBorrowGuard
RAII guard that releases a segment borrow when dropped.
SegmentBorrowRegistry
Instruction-scoped segment borrow registry.

Enums§

AccessKind
Read or write access intent for a segment borrow.

Constants§

MAX_SEGMENT_BORROWS
Maximum simultaneous segment borrows per instruction.