feat: expose AxisLink::get() and version() as public#21
Open
mmavka wants to merge 1 commit intodonkeyteethUX:mainfrom
Open
feat: expose AxisLink::get() and version() as public#21mmavka wants to merge 1 commit intodonkeyteethUX:mainfrom
mmavka wants to merge 1 commit intodonkeyteethUX:mainfrom
Conversation
Changes visibility of AxisLink::get() and AxisLink::version() from pub(crate) to pub. Both are pure readers over an Arc<RwLock<_>> 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.
Owner
|
Is there a real human with a real use-case behind this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
AxisLinkis already a public struct in theiced_plotAPI — users createone with
AxisLink::new()and pass it toPlotWidgetBuilder::with_x_axis_link/
with_y_axis_linkto synchronize pan/zoom across multiple plots. Theinternal state (center position, half-extent, version counter) is updated
on every camera change via the
update_axis_linkspath.However, the two reader methods —
get()andversion()— are currentlypub(crate), meaning downstream code can create and attach anAxisLinkbut cannot observe the state it carries. This limits the linkto same-crate synchronization only.
Exposing these readers lets downstream code do three useful things without
any additional state or plumbing:
version()(bumped on everycamera change) — avoids subscribing to
PlotUiMessage::RenderUpdatejust to know whether the viewport moved.
(minimap, orderbook ladder, correlated chart) by reading the linked
position/half-extent directly.
center+extent is sufficient to restore the view.
What this PR does
AxisLink::get(&self) -> (f64, f64, u64)frompub(crate)topub.AxisLink::version(&self) -> u64frompub(crate)topub.#[must_use]attributes and# Panicsdoc sections to the newly-publicmethods, keeping the crate clippy::pedantic clean.
get()to document the return-tuple semanticsand the version-counter use case.
API additions
Non-breaking
modifier changes).
Arc<RwLock<_>>already internalto a public struct. Exposing them adds no new invariants and no new
thread-safety concerns beyond those already implied by
AxisLinkbeing
Clone + Send + Sync.Example use case
Alternatives considered
AxisLinkcrate-private and adding a different getter onPlotWidget. Works, but duplicates state: the link already carriesthe data; exposing its readers is the minimal change.
ViewportChangedmessage variant. Usefulcomplement but orthogonal; this PR is the cheapest path to polling-based
change detection.
pub. Would leak theArc<RwLock<_>>structure, discouraging future changes to the locking strategy.
Keeping the method surface means the implementation can evolve.
Related
None.