History

more docs for owned git-object

Sebastian Thiel committed 5 years ago

Commit b79101d1 parent 171d26912 files · +42 −6Browse files

Showing the changes to git-object/src/commit.rs (1 of 12 files). Show all

Unified · Split

git-object/src/commit.rs+11−0
@@ -1,28 +1,39 @@
11 use crate::borrowed;
22 use bstr::{BStr, ByteSlice};
33
4+/// An iterator over extra headers in [owned][crate::owned::Commit] and [borrowed][borrowed::Commit] commits.
45 pub struct ExtraHeaders<I> {
56 inner: I,
67 }
78
9+/// Instantiation and convenience
810 impl<'a, I> ExtraHeaders<I>
911 where
1012 I: Iterator<Item = (&'a BStr, &'a BStr)>,
1113 {
14+ /// Create a new instance from an iterator over tuples of (name, value) pairs.
1215 pub fn new(iter: I) -> Self {
1316 ExtraHeaders { inner: iter }
1417 }
18+ /// Find the _value_ of the _first_ header with the given `name`.
1519 pub fn find(mut self, name: &str) -> Option<&'a BStr> {
1620 self.inner
1721 .find_map(move |(k, v)| if k == name.as_bytes().as_bstr() { Some(v) } else { None })
1822 }
23+ /// Return an iterator over all _values_ of headers with the given `name`.
1924 pub fn find_all(self, name: &'a str) -> impl Iterator<Item = &'a BStr> {
2025 self.inner
2126 .filter_map(move |(k, v)| if k == name.as_bytes().as_bstr() { Some(v) } else { None })
2227 }
28+ /// Return an iterator over all git mergetags.
29+ ///
30+ /// A merge tag is a tag object embedded within the respective header field of a commit, making
31+ /// it a child object of sorts.
2332 pub fn mergetags(self) -> impl Iterator<Item = Result<borrowed::Tag<'a>, borrowed::Error>> {
2433 self.find_all("mergetag").map(|b| borrowed::Tag::from_bytes(b))
2534 }
35+
36+ /// Return the cryptographic signature provided by gpg/pgp verbatim
2637 pub fn pgp_signature(self) -> Option<&'a BStr> {
2738 self.find("gpgsig")
2839 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t