From 3441ca4a0d69e2bfeafa0801a220ba0d35b09991 Mon Sep 17 00:00:00 2001 From: mmavka Date: Tue, 14 Apr 2026 22:54:00 +0200 Subject: [PATCH] feat: expose AxisLink::get() and version() as public Changes visibility of AxisLink::get() and AxisLink::version() from pub(crate) to pub. Both are pure readers over an Arc> already internal to a public struct; exposing them adds no new invariants. Adds #[must_use] attribute and # Panics sections to the newly-public methods to stay clippy::pedantic clean. Enables downstream code to poll axis-link state for cheap viewport-change detection (version counter) without subscribing to PlotUiMessage::RenderUpdate or pattern-matching its doc-hidden payload. --- src/axis_link.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/axis_link.rs b/src/axis_link.rs index 8d27cf0..65f0a83 100644 --- a/src/axis_link.rs +++ b/src/axis_link.rs @@ -23,8 +23,22 @@ impl AxisLink { Default::default() } - /// Get the current position and half extent - pub(crate) fn get(&self) -> (f64, f64, u64) { + /// Get the current position, half-extent, and version counter. + /// + /// Returns `(center, half_extent, version)`. The data-space axis range + /// covered by the linked plots is `[center - half_extent, center + half_extent]`. + /// + /// The version counter is bumped on every camera change; downstream + /// code can poll it to detect viewport updates without plumbing the + /// `PlotUiMessage::RenderUpdate` stream. + /// + /// # Panics + /// + /// Panics only if the internal `RwLock` has been poisoned by a prior + /// panic on another thread while holding the write lock. Not expected + /// in normal operation. + #[must_use] + pub fn get(&self) -> (f64, f64, u64) { let inner = self.inner.read().unwrap(); (inner.position, inner.half_extent, inner.version) } @@ -37,8 +51,19 @@ impl AxisLink { inner.version = inner.version.wrapping_add(1); } - /// Get the current version - pub(crate) fn version(&self) -> u64 { + /// Get the current version counter. + /// + /// The counter is bumped on every camera change. A cheap way to detect + /// whether the viewport has moved since the last observation without + /// locking the value state. + /// + /// # Panics + /// + /// Panics only if the internal `RwLock` has been poisoned by a prior + /// panic on another thread while holding the write lock. Not expected + /// in normal operation. + #[must_use] + pub fn version(&self) -> u64 { self.inner.read().unwrap().version } }