Struct git_repository::mailmap::Snapshot
source · [−]pub struct Snapshot { /* private fields */ }
Expand description
A data-structure to efficiently store a list of entries for optimal, case-insensitive lookup by email and optionally name to find mappings to new names and/or emails.
The memory layout is efficient, even though lots of small allocations are performed to store strings of emails and names.
Implementations
sourceimpl Snapshot
impl Snapshot
sourcepub fn from_bytes(buf: &[u8]) -> Snapshot
pub fn from_bytes(buf: &[u8]) -> Snapshot
Create a new snapshot from the given bytes buffer, ignoring all parse errors that may occour on a line-by-line basis.
This is similar to what git does.
sourcepub fn new<'a>(entries: impl IntoIterator<Item = Entry<'a>>) -> Snapshot
pub fn new<'a>(entries: impl IntoIterator<Item = Entry<'a>>) -> Snapshot
Create a new instance from entries
.
These can be obtained using crate::parse().
sourcepub fn merge<'a>(
&mut self,
entries: impl IntoIterator<Item = Entry<'a>>
) -> &mut Snapshot
pub fn merge<'a>(
&mut self,
entries: impl IntoIterator<Item = Entry<'a>>
) -> &mut Snapshot
Merge the given entries
into this instance, possibly overwriting existing mappings with
new ones should they collide.
sourcepub fn entries(&self) -> Vec<Entry<'_>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn entries(&self) -> Vec<Entry<'_>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Transform our acceleration structure into a list of entries.
Note that the order is different from how they were obtained initially, and are explicitly ordered by (old_email, old_name).
sourcepub fn try_resolve_ref(
&'a self,
signature: SignatureRef<'_>
) -> Option<ResolvedSignature<'a>>
pub fn try_resolve_ref(
&'a self,
signature: SignatureRef<'_>
) -> Option<ResolvedSignature<'a>>
Try to resolve signature
by its contained email and name and provide resolved/mapped names as reference.
Return None
if no such mapping was found.
Note that opposed to what git seems to do, we also normalize the case of email addresses to match the one
given in the mailmap. That is, if Alex@example.com
is the current email, it will be matched and replaced with
alex@example.com
. This leads to better mapping results and saves entries in the mailmap.
This is the fastest possible lookup as there is no allocation.
sourcepub fn try_resolve(&self, signature: SignatureRef<'_>) -> Option<Signature>
pub fn try_resolve(&self, signature: SignatureRef<'_>) -> Option<Signature>
Try to resolve signature
by its contained email and name and provide resolved/mapped names as owned signature,
with the mapped name and/or email replaced accordingly.
Return None
if no such mapping was found.
sourcepub fn resolve(&self, signature: SignatureRef<'_>) -> Signature
pub fn resolve(&self, signature: SignatureRef<'_>) -> Signature
Like try_resolve()
, but always returns an owned signature, which might be a copy
of signature
if no mapping was found.
Note that this method will always allocate.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl UnwindSafe for Snapshot
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more