pub struct ViewSpec { /* private fields */ }Expand description
A normalized view: included prefixes, excluded prefixes, and spine file
names. Construct with ViewSpec::new; two specs selecting the same
paths normalize to the same value and the same ViewSpec::id.
Implementations§
Source§impl ViewSpec
impl ViewSpec
Sourcepub fn new<I, E, S>(include: I, exclude: E, spine_files: S) -> Result<ViewSpec>where
I: IntoIterator,
I::Item: AsRef<str>,
E: IntoIterator,
E::Item: AsRef<str>,
S: IntoIterator,
S::Item: AsRef<str>,
pub fn new<I, E, S>(include: I, exclude: E, spine_files: S) -> Result<ViewSpec>where
I: IntoIterator,
I::Item: AsRef<str>,
E: IntoIterator,
E::Item: AsRef<str>,
S: IntoIterator,
S::Item: AsRef<str>,
Build a normalized view. Prefixes are normalized like sparse-cone
prefixes (/apps/web/ → apps/web); "" (or /) includes the whole
repo. Redundant entries are dropped: an include covered by another
include or by an exclude, and an exclude that no include reaches or
that another exclude covers.
Errors on an invalid path, an exclude of the whole repo, a spine name that isn’t a single path component, or a view left including nothing.
pub fn include(&self) -> &[String]
pub fn exclude(&self) -> &[String]
pub fn spine_files(&self) -> &[String]
Sourcepub fn union(&self, other: &ViewSpec) -> Result<ViewSpec>
pub fn union(&self, other: &ViewSpec) -> Result<ViewSpec>
A new view with this one’s includes and spine files plus other’s,
keeping an exclude only where both views excluded it or other
doesn’t reach it — the union of what the two views select.
Sourcepub fn to_canonical(&self) -> String
pub fn to_canonical(&self) -> String
The canonical text form: one line per entry, +prefix for includes,
-prefix for excludes, =name for spine files, in that order. A bare
+ includes the whole repo. Round-trips with ViewSpec::parse and
is what ViewSpec::id hashes, so it’s also the wire form.
Sourcepub fn parse(text: &str) -> Result<ViewSpec>
pub fn parse(text: &str) -> Result<ViewSpec>
Parse ViewSpec::to_canonical output (or any hand-written text in
that shape; blank lines are ignored and the result is normalized).
Sourcepub fn id(&self) -> Hash
pub fn id(&self) -> Hash
A stable identifier for this view: BLAKE3 over a version tag and the canonical form.
Sourcepub fn covers(&self, path: &str) -> bool
pub fn covers(&self, path: &str) -> bool
Is path inside an included prefix and not excluded? Spine files are
not counted; see ViewSpec::includes_file.
Sourcepub fn includes_file(&self, path: &str) -> bool
pub fn includes_file(&self, path: &str) -> bool
Does the view keep the file at path? True when the view
covers it, or when it is a spine file in a
directory the view passes through on the way to an included prefix.
Trait Implementations§
impl Eq for ViewSpec
impl StructuralPartialEq for ViewSpec
Auto Trait Implementations§
impl Forget for ViewSpec
impl Freeze for ViewSpec
impl Move for ViewSpec
impl RefUnwindSafe for ViewSpec
impl Send for ViewSpec
impl Sync for ViewSpec
impl Unpin for ViewSpec
impl UnsafeUnpin for ViewSpec
impl UnwindSafe for ViewSpec
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