Struct git_object::Data
source · [−]Expand description
A borrowed object using a slice as backing buffer, or in other words a bytes buffer that knows the kind of object it represents.
Fields
kind: Kind
kind of object
data: &'a [u8]
decoded, decompressed data, owned by a backing store.
Implementations
sourceimpl<'a> Data<'a>
impl<'a> Data<'a>
sourcepub fn new(kind: Kind, data: &'a [u8]) -> Data<'a>
pub fn new(kind: Kind, data: &'a [u8]) -> Data<'a>
Constructs a new data object from kind
and data
.
sourcepub fn decode(&self) -> Result<ObjectRef<'a>, Error>
pub fn decode(&self) -> Result<ObjectRef<'a>, Error>
Decodes the data in the backing slice into a ObjectRef
, allowing to access all of its data
conveniently. The cost of parsing an object is negligible.
Note that mutable, decoded objects can be created from Data
using crate::ObjectRef::into_owned()
.
sourcepub fn try_into_tree_iter(self) -> Option<TreeRefIter<'a>>
pub fn try_into_tree_iter(self) -> Option<TreeRefIter<'a>>
Returns this object as tree iterator to parse entries one at a time to avoid allocations, or
None
if this is not a tree object.
sourcepub fn try_into_commit_iter(self) -> Option<CommitRefIter<'a>>
pub fn try_into_commit_iter(self) -> Option<CommitRefIter<'a>>
Returns this object as commit iterator to parse tokens one at a time to avoid allocations, or
None
if this is not a commit object.
sourcepub fn try_into_tag_iter(self) -> Option<TagRefIter<'a>>
pub fn try_into_tag_iter(self) -> Option<TagRefIter<'a>>
Returns this object as tag iterator to parse tokens one at a time to avoid allocations, or
None
if this is not a tag object.
Trait Implementations
sourceimpl<'a> Ord for Data<'a>
impl<'a> Ord for Data<'a>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl<'a> PartialOrd<Data<'a>> for Data<'a>
impl<'a> PartialOrd<Data<'a>> for Data<'a>
sourcefn partial_cmp(&self, other: &Data<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &Data<'a>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more