Struct gix_object::Data
source · 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.
Trait Implementations§
source§impl<'a> Ord for Data<'a>
impl<'a> Ord for Data<'a>
source§impl<'a> PartialEq for Data<'a>
impl<'a> PartialEq for Data<'a>
source§impl<'a> PartialOrd for Data<'a>
impl<'a> PartialOrd for Data<'a>
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