Struct gix_object::commit::MessageRef
source · pub struct MessageRef<'a> {
pub title: &'a BStr,
pub body: Option<&'a BStr>,
}
Expand description
A parsed commit message that assumes a title separated from the body by two consecutive newlines.
Titles can have any amount of whitespace
Fields§
§title: &'a BStr
The title of the commit, as separated from the body with two consecutive newlines. The newlines are not included.
body: Option<&'a BStr>
All bytes not consumed by the title, excluding the separating newlines.
The body is None
if there was now title separation or the body was empty after the separator.
Implementations§
source§impl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
sourcepub fn from_bytes(input: &'a [u8]) -> Self
pub fn from_bytes(input: &'a [u8]) -> Self
Parse the given input
as message.
Note that this cannot fail as everything will be interpreted as title if there is no body separator.
sourcepub fn summary(&self) -> Cow<'a, BStr>
pub fn summary(&self) -> Cow<'a, BStr>
Produce a short commit summary for the message title.
This means the following
- Take the subject line which is delimited by two newlines (\n\n)
- transform intermediate consecutive whitespace including \r into one space
The resulting summary will have folded whitespace before a newline into spaces and stopped that process once two consecutive newlines are encountered.
Trait Implementations§
source§impl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
source§fn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for MessageRef<'a>
impl<'a> Debug for MessageRef<'a>
source§impl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
impl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> Hash for MessageRef<'a>
impl<'a> Hash for MessageRef<'a>
source§impl<'a> Ord for MessageRef<'a>
impl<'a> Ord for MessageRef<'a>
source§fn cmp(&self, other: &MessageRef<'a>) -> Ordering
fn cmp(&self, other: &MessageRef<'a>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'a> PartialEq for MessageRef<'a>
impl<'a> PartialEq for MessageRef<'a>
source§fn eq(&self, other: &MessageRef<'a>) -> bool
fn eq(&self, other: &MessageRef<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> PartialOrd for MessageRef<'a>
impl<'a> PartialOrd for MessageRef<'a>
source§fn partial_cmp(&self, other: &MessageRef<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageRef<'a>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more