pub trait ReadSegmentHandle: Send + Sync {
type Segment: ReadSegmentEntry + ?Sized;
// Required methods
fn read_segment(&self) -> RwLockReadGuard<'_, Self::Segment>;
fn segment_arc(&self) -> Arc<RwLock<Self::Segment>>;
}Expand description
A handle to a single segment that can be read-locked to yield a [ReadSegmentEntry].
Abstracting over the handle (rather than the segment type) keeps the read path monomorphic for
homogeneous callers — a read-only follower’s handle is the concrete
Arc<RwLock<ReadOnlySegment<S>>> — while the read-write shard, whose holder is intrinsically
heterogeneous (Segment and ProxySegment coexist during optimization), uses the
[LockedSegment] enum. Dynamic dispatch is confined to the LockedSegment impl, mirroring the
pre-existing [LockedSegment::get_read].
Send + Sync so a snapshot of handles can be shared across the shard’s search thread pool and
read in parallel (see EdgeReadView::par_map_segments). Both concrete handles —
Arc<RwLock<ReadOnlySegment<S>>> and [LockedSegment] — already satisfy this.
Required Associated Types§
Required Methods§
Sourcefn read_segment(&self) -> RwLockReadGuard<'_, Self::Segment>
fn read_segment(&self) -> RwLockReadGuard<'_, Self::Segment>
Acquire a read guard. One guard is held for the whole per-segment operation, so reads that call several methods on the same segment observe a consistent state.
Sourcefn segment_arc(&self) -> Arc<RwLock<Self::Segment>>
fn segment_arc(&self) -> Arc<RwLock<Self::Segment>>
Owned handle for the retrieval / version-dedup path (retrieve_over).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".