pub struct SymbolicRefs(/* private fields */);Expand description
Maintains an acyclic set of symbolic references. Note that dangling references are not detected.
Internally, targets are stored as Target, which distinguishes
direct (qualified) targets from symbolic (intermediate) ones. This
means resolution and cycle-checking can pattern-match on the variant
rather than re-parsing the string.
§Deserialization Order
Deserialization validates entries in iteration order via
TryFrom<IndexMap>. This means deserialization only succeeds if
symbolic reference whose target is another symbolic
reference appears after that target in the JSON.
For example,
{"MAIN": "refs/heads/master", "HEAD": "MAIN"} is valid, but
{"HEAD": "MAIN", "MAIN": "refs/heads/master"} is not.
To ensure that serialization and deserialization are inverses,
we must ensure that insertion order and iteration order are the same.
We do this by using IndexMap internally, which preserves this property,
and enabling the feature preserve_order of the serde_json crate.
Normally, JSON objects are unordered (see RFC 8259, Sec. 4). Any compatible (de-)serializer must preserve key order.
Implementations§
Source§impl SymbolicRefs
Read-only access.
impl SymbolicRefs
Read-only access.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&RefString, &Target)>
pub fn iter(&self) -> impl Iterator<Item = (&RefString, &Target)>
Returns an iterator over all contained symbolic references, as pairs
of their name and Target.
Sourcepub fn iter_resolved(
&self,
) -> impl Iterator<Item = (&RefString, &Qualified<'static>)>
pub fn iter_resolved( &self, ) -> impl Iterator<Item = (&RefString, &Qualified<'static>)>
Returns an iterator over all contained symbolic references that
resolve to a direct (qualified) target. The yielded target is the
final Qualified reference after chasing through any intermediate
symbolic references.
Source§impl SymbolicRefs
Utilities for handling of HEAD.
impl SymbolicRefs
Utilities for handling of HEAD.
Sourcepub fn head(branch_name: &RefString) -> SymbolicRefs
pub fn head(branch_name: &RefString) -> SymbolicRefs
Construct SymbolicRefs for the single symbolic reference HEAD
targeting /refs/heads/<branch_name>.
Sourcepub fn resolve_head(&self) -> Option<&Qualified<'static>>
pub fn resolve_head(&self) -> Option<&Qualified<'static>>
Convenience method to get the resolved target of the HEAD reference.
Returns the final Qualified reference after chasing the chain.
See also SymbolicRefs::head.
Source§impl SymbolicRefs
Mutability.
impl SymbolicRefs
Mutability.
Sourcepub fn combine(&mut self, other: SymbolicRefs) -> Result<(), InsertionError>
pub fn combine(&mut self, other: SymbolicRefs) -> Result<(), InsertionError>
Consume other by iteratively inserting into self.
Trait Implementations§
Source§impl Clone for SymbolicRefs
impl Clone for SymbolicRefs
Source§fn clone(&self) -> SymbolicRefs
fn clone(&self) -> SymbolicRefs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SymbolicRefs
impl Debug for SymbolicRefs
Source§impl Default for SymbolicRefs
impl Default for SymbolicRefs
Source§fn default() -> SymbolicRefs
fn default() -> SymbolicRefs
Source§impl<'de> Deserialize<'de> for SymbolicRefs
impl<'de> Deserialize<'de> for SymbolicRefs
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolicRefs, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SymbolicRefs, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SymbolicRefs
impl PartialEq for SymbolicRefs
Source§fn eq(&self, other: &SymbolicRefs) -> bool
fn eq(&self, other: &SymbolicRefs) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SymbolicRefs
impl Serialize for SymbolicRefs
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<IndexMap<Unprotected<RefString>, Unprotected<RefString>>> for SymbolicRefs
impl TryFrom<IndexMap<Unprotected<RefString>, Unprotected<RefString>>> for SymbolicRefs
Source§type Error = InsertionError
type Error = InsertionError
impl Eq for SymbolicRefs
impl StructuralPartialEq for SymbolicRefs
Auto Trait Implementations§
impl Freeze for SymbolicRefs
impl RefUnwindSafe for SymbolicRefs
impl Send for SymbolicRefs
impl Sync for SymbolicRefs
impl Unpin for SymbolicRefs
impl UnsafeUnpin for SymbolicRefs
impl UnwindSafe for SymbolicRefs
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§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