Struct git_nomad::snapshot::Snapshot

source ·
pub struct Snapshot<'a, Ref> {
    pub local_branches: HashSet<Branch<'static>>,
    pub nomad_refs: Vec<NomadRef<'a, Ref>>,
    _private: (),
}
Expand description

A point in time view of refs we care about. Snapshot is only for local branches and refs and thus is scoped under a specific User.

Fields§

§local_branches: HashSet<Branch<'static>>

The active branches in this clone that the user manipulates directly with git branch etc.

§nomad_refs: Vec<NomadRef<'a, Ref>>

The refs that nomad manages to follow the local branches.

§_private: ()

Force all callers to go through Snapshot::new which can validate invariants.

Implementations§

source§

impl<Ref> Snapshot<'_, Ref>

source

pub fn new<'a>( user: &'a User<'_>, local_branches: HashSet<Branch<'static>>, nomad_refs: Vec<NomadRef<'a, Ref>>, ) -> Snapshot<'a, Ref>

Smart constructor that enforces the “scoped under a specific User” invariant.

§Panics

If nomad_refs points to a different User than the user passed in. This indicates serious programmer error.

source§

impl<'a, Ref> Snapshot<'a, Ref>

source

pub fn prune_deleted_branches( self, host: &Host<'_>, remote_nomad_refs: &RemoteNomadRefSet, ) -> Vec<PruneFrom<'a, Ref>>

Find nomad host branches that can be pruned because:

  1. The local branch they were based on no longer exists.
  2. The remote branch they were based on no longer exists.
source

pub fn prune_by_hosts( self, host_filter: impl Fn(&Host<'_>) -> bool, ) -> Vec<PruneFrom<'a, Ref>>

Return all nomad branches for specific hosts.

source

pub fn sorted_hosts_and_branches( self, ) -> Vec<(Host<'a>, Vec<NomadRef<'a, Ref>>)>

Return all NomadRefs grouped by host in sorted order.

Auto Trait Implementations§

§

impl<'a, Ref> Freeze for Snapshot<'a, Ref>

§

impl<'a, Ref> RefUnwindSafe for Snapshot<'a, Ref>
where Ref: RefUnwindSafe,

§

impl<'a, Ref> Send for Snapshot<'a, Ref>
where Ref: Send,

§

impl<'a, Ref> Sync for Snapshot<'a, Ref>
where Ref: Sync,

§

impl<'a, Ref> Unpin for Snapshot<'a, Ref>
where Ref: Unpin,

§

impl<'a, Ref> UnwindSafe for Snapshot<'a, Ref>
where Ref: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.