1use crate::error::{GitError, Result};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum ObjectKind {
5 Commit,
6 Tree,
7 Blob,
8 Tag,
9}
10
11impl ObjectKind {
12 pub fn from_bytes(b: &[u8]) -> Result<Self> {
13 match b {
14 b"commit" => Ok(Self::Commit),
15 b"tree" => Ok(Self::Tree),
16 b"blob" => Ok(Self::Blob),
17 b"tag" => Ok(Self::Tag),
18 other => Err(GitError::InvalidObject(format!(
19 "unknown object kind: {:?}",
20 String::from_utf8_lossy(other)
21 ))),
22 }
23 }
24}
25
26#[derive(Debug, Clone)]
27pub struct RawObject {
28 pub kind: ObjectKind,
29 pub data: Vec<u8>,
30 pub verified: bool,
32}