pub trait ObjectTrait:
Send
+ Sync
+ Display {
// Required methods
fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>
where Self: Sized;
fn get_type(&self) -> ObjectType;
fn get_size(&self) -> usize;
fn to_data(&self) -> Result<Vec<u8>, GitError>;
// Provided methods
fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Self
where Self: Sized { ... }
fn object_hash(&self) -> Result<ObjectHash, GitError> { ... }
}Expand description
The Object Trait Defines the common interface for all Git object types, including blobs, trees, commits, and tags.
Required Methods§
Sourcefn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
Creates a new object from a byte slice.
Sourcefn get_type(&self) -> ObjectType
fn get_type(&self) -> ObjectType
Returns the type of the object.
fn get_size(&self) -> usize
fn to_data(&self) -> Result<Vec<u8>, GitError>
Provided Methods§
Sourcefn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
Generate a new Object from a ReadBoxed<BufRead>.
the input size,is only for new a vec with directive space allocation
the input data stream and output object should be plain base object .