pub struct Lens { /* private fields */ }Expand description
Everything that decides whether a claim is on screen.
Cloned into every mark, which is why it is a value rather than a handle into the view: a mark has to keep meaning what the reader could see when they made it, and a mark holding a reference to the current view would mean the opposite of that.
Implementations§
Source§impl Lens
impl Lens
Sourcepub fn of(tiers: Tiers, kinds: Kinds) -> Self
pub fn of(tiers: Tiers, kinds: Kinds) -> Self
A lens on the two axes directly, which is the general door: Lens::showing is the
preset shorthand over it.
Sourcepub fn matching(self, pattern: Option<Regex>) -> Self
pub fn matching(self, pattern: Option<Regex>) -> Self
The same lens with pattern over it, or with none.
Sourcepub fn with_tiers(self, tiers: Tiers) -> Self
pub fn with_tiers(self, tiers: Tiers) -> Self
The same lens with the tier axis moved, and the kind axis untouched.
The two editors exist so that the axes are independently reachable by a reader, not only inside this file: a model that can express “every cache a rule named” while no key can reach it is not expressible in any sense the request meant.
Sourcepub fn with_kinds(self, kinds: Kinds) -> Self
pub fn with_kinds(self, kinds: Kinds) -> Self
The same lens with the kind axis moved, and the tier axis untouched.
Sourcepub fn files(&self) -> bool
pub fn files(&self) -> bool
Whether gitignored files are on screen.
§Why an axis of its own rather than a third tier
A gitignored file is a tier-two claim, so a third value on the tier axis is the first
idea and it does not survive the presets. Each step of f’s cycle moves exactly one
axis, and all — “everything the scan found” — would have to widen the tier axis and
the kind axis together to reach files. The / pattern already had this shape and was
resolved the same way: it decides what is on screen, it is orthogonal to both axes, and
no preset touches it. Files are the same, which also means turning them on is not
undone by cycling the view.
It is independently reachable, which is what the request asked for in so many words:
i toggles this and nothing else, so gitignored files come and go without disturbing
gitignored directories.
Sourcepub fn with_files(self, files: bool) -> Self
pub fn with_files(self, files: bool) -> Self
The same lens showing, or not showing, gitignored files. Both other axes untouched.
Sourcepub fn preset(&self) -> Option<Preset>
pub fn preset(&self) -> Option<Preset>
Which preset this lens sits on, if it sits on one.
Unambiguous, because the four presets occupy four distinct points — which is what the footer needs in order to name a view honestly, and it is why nothing has to remember which step of the cycle the reader took to get here. A lens the axis keys built lands off all four and says so.
The pattern is deliberately not consulted, and neither is the files axis: both narrow
or widen whatever the two axes left, so dependencies with a pattern over it and
files showing beside it is still dependencies.
Sourcepub fn axes_label(&self) -> String
pub fn axes_label(&self) -> String
How the footer spells the axes when the reader has moved off every preset.
The files axis is named only when it is on, and that asymmetry is deliberate: off is where every view starts, so saying it everywhere would spend a third of the line on the absence of something. When it is on it changes what a row means, so it is said.
Sourcepub fn is_everything(&self) -> bool
pub fn is_everything(&self) -> bool
Whether this lens hides nothing at all, which is the fast path the whole front end takes when a reader has not narrowed anything.
Note that no preset reaches it: all widens both axes and leaves files where the
reader put them, so a run that has never pressed i is narrowed however far f has
been cycled. That is what the header’s out-of-view count is for.
Sourcepub fn matches(&self, hit: &Hit) -> bool
pub fn matches(&self, hit: &Hit) -> bool
Whether this claim is on screen.
The three axes are visibly independent here, which is the whole reason for the shape.
Where a claim came from decides one of them — a rule, the gitignore fallback, or the
fallback on a file — and what it is decides the kind axis, whoever found it. That
second half is what lets .env files be narrowed to on their own without a mode
anybody had to anticipate, and it leaves the tier-two directory judged by the tier
axis and never by the kind axis, since it has no kind to judge.
Trait Implementations§
impl Eq for Lens
Source§impl Hash for Lens
impl Hash for Lens
Source§fn hash<H: Hasher>(&self, state: &mut H)
fn hash<H: Hasher>(&self, state: &mut H)
Exactly what Lens::eq reads, in the same order, because a hash that disagreed with
equality is a lens that changed without anybody watching it being told — and
super::treemap watches this one to decide whether a picture is still the right
one. The pattern goes in as its source text for equality’s own reason.
Auto Trait Implementations§
impl Freeze for Lens
impl RefUnwindSafe for Lens
impl Send for Lens
impl Sync for Lens
impl Unpin for Lens
impl UnsafeUnpin for Lens
impl UnwindSafe for Lens
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more