pub struct GitObject {
pub gtype: GitType,
pub body: Vec<u8>,
}Expand description
An encoded git object: type + body (the bytes after the
"<type> <len>\0" header).
Fields§
§gtype: GitType§body: Vec<u8>Implementations§
Source§impl GitObject
impl GitObject
Sourcepub fn loose_path(git_dir: &Path, id: &Sha1Id) -> PathBuf
pub fn loose_path(git_dir: &Path, id: &Sha1Id) -> PathBuf
Loose-object path under a .git (or bare repo) directory.
Sourcepub fn write_loose(&self, git_dir: &Path) -> Result<Sha1Id, BridgeError>
pub fn write_loose(&self, git_dir: &Path) -> Result<Sha1Id, BridgeError>
Write this object loose into git_dir/objects/, returning its
id. Idempotent: an existing object file is left untouched
(same bytes by content addressing). The write is
temp-file + rename so a crash never leaves a torn object.
Source§impl GitObject
impl GitObject
Sourcepub fn parse_raw(raw: &[u8]) -> Option<Self>
pub fn parse_raw(raw: &[u8]) -> Option<Self>
Parse "<type> <len>\0<body>" bytes (the inverse of
Self::raw; what a zlib-decompressed loose object contains).
Sourcepub fn read_loose(git_dir: &Path, id: &Sha1Id) -> Result<Self, BridgeError>
pub fn read_loose(git_dir: &Path, id: &Sha1Id) -> Result<Self, BridgeError>
Read and parse a loose object from a git objects dir,
verifying the bytes hash back to the requested id (also
rejects non-canonical headers, since Self::id re-renders
the canonical form).
Trait Implementations§
impl Eq for GitObject
impl StructuralPartialEq for GitObject
Auto Trait Implementations§
impl Freeze for GitObject
impl RefUnwindSafe for GitObject
impl Send for GitObject
impl Sync for GitObject
impl Unpin for GitObject
impl UnsafeUnpin for GitObject
impl UnwindSafe for GitObject
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
Mutably borrows from an owned value. Read more