pub struct Data<'a> {
pub kind: Kind,
pub data: &'a [u8],
}
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§
Source§impl<'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.