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
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<'a> PartialEq<Data<'a>> for Data<'a>
impl<'a> PartialEq<Data<'a>> for Data<'a>
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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<'a> Eq for Data<'a>
impl<'a> StructuralEq for Data<'a>
impl<'a> StructuralPartialEq for Data<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for Data<'a>
impl<'a> Send for Data<'a>
impl<'a> Sync for Data<'a>
impl<'a> Unpin for Data<'a>
impl<'a> UnwindSafe for Data<'a>
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