Skip to main content

ViewSpec

Struct ViewSpec 

Source
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

Source

pub fn new<I, E, S>(include: I, exclude: E, spine_files: S) -> Result<ViewSpec>

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.

Source

pub fn full() -> ViewSpec

The whole repository, with no exclusions or spine files.

Source

pub fn include(&self) -> &[String]

Source

pub fn exclude(&self) -> &[String]

Source

pub fn spine_files(&self) -> &[String]

Source

pub fn is_full(&self) -> bool

True when the view selects the whole repository.

Source

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.

Source

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.

Source

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).

Source

pub fn id(&self) -> Hash

A stable identifier for this view: BLAKE3 over a version tag and the canonical form.

Source

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.

Source

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§

Source§

impl Clone for ViewSpec

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ViewSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ViewSpec

Source§

impl Hash for ViewSpec

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ViewSpec

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ViewSpec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.