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> PartialOrd for Data<'a>
impl<'a> PartialOrd for Data<'a>
impl<'a> Copy for Data<'a>
impl<'a> Eq for Data<'a>
impl<'a> StructuralPartialEq for Data<'a>
Auto Trait Implementations§
impl<'a> Freeze for Data<'a>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)