bit_object

    Git object model (gix-object equivalent)

    git
    object
    blob
    tree
    commit
    Download zip
    Author
    Version
    0.47.0
    License
    Apache-2.0
    Last updated
    7 hours ago
    Downloads
    904

    Dependencies

    GitError

    pub(all) suberror GitError {
    InvalidObject(String)
    HashMismatch(String, String)
    PackfileError(String)
    ProtocolError(String)
    IoError(String)
    } derive(Eq,
    Debug
    )

    Git operation errors
    impl Show for GitError

    Commit

    pub struct Commit {
    tree : ObjectId
    parents : Array[ObjectId]
    author : String
    author_time : Int64
    author_tz : String
    committer : String
    commit_time : Int64
    committer_tz : String
    message : String
    encoding : String
    verbatim_message : Bool
    }

    Git commit object

    Commit::new

    fn Commit::new(tree : ObjectId, parents : Array[ObjectId], author : String, author_time : Int64, author_tz : String, committer : String, commit_time : Int64, committer_tz : String, message : String, encoding? : String, verbatim_message? : Bool) -> Commit

    HashAlgorithm

    pub(all) enum HashAlgorithm {
    Sha1
    Sha256
    } derive(Eq,
    Debug
    )

    HashAlgorithm::from_string

    fn HashAlgorithm::from_string(s : String) -> HashAlgorithm raise GitError

    HashAlgorithm::hash_size

    fn HashAlgorithm::hash_size(self : HashAlgorithm) -> Int

    HashAlgorithm::hex_size

    fn HashAlgorithm::hex_size(self : HashAlgorithm) -> Int

    HashAlgorithm::name

    fn HashAlgorithm::name(self : HashAlgorithm) -> String

    HashAlgorithm::zero_hex

    fn HashAlgorithm::zero_hex(self : HashAlgorithm) -> String

    HashState

    pub(all) enum HashState {
    HS1(Sha1State)
    HS256(Sha256State)
    }

    HashState::finish

    fn HashState::finish(self : HashState) -> ObjectId

    HashState::new

    fn HashState::new(algo : HashAlgorithm) -> HashState

    HashState::reset

    fn HashState::reset(self : HashState) -> Unit

    HashState::update

    fn HashState::update(self : HashState, data : Bytes) -> Unit

    HashState::update_byte

    fn HashState::update_byte(self : HashState, b : Byte) -> Unit

    HashState::update_slice

    fn HashState::update_slice(self : HashState, data : Bytes, offset : Int, len : Int) -> Unit

    HashState::update_string

    fn HashState::update_string(self : HashState, s : String) -> Unit

    ObjectId

    pub struct ObjectId {
    bytes : FixedArray[Byte]
    }

    Object identifier (20 bytes for SHA-1, 32 bytes for SHA-256)
    impl Eq for ObjectId
    impl Hash for ObjectId
    impl Show for ObjectId

    ObjectId::from_bytes

    fn ObjectId::from_bytes(data : Bytes) -> ObjectId raise GitError

    Create ObjectId from Bytes (must be exactly 20 or 32 bytes)

    ObjectId::from_bytes_at

    fn ObjectId::from_bytes_at(data : Bytes, offset : Int, hash_size? : Int) -> ObjectId

    Create ObjectId from Bytes at offset (for parsing packed data). Reads hash_size bytes (default 20 for SHA-1).

    ObjectId::from_hex

    fn ObjectId::from_hex(hex : String) -> ObjectId raise GitError

    ObjectId::hash_size

    fn ObjectId::hash_size(self : ObjectId) -> Int

    Return the byte length of this ObjectId (20 for SHA-1, 32 for SHA-256).

    ObjectId::is_zero

    fn ObjectId::is_zero(self : ObjectId) -> Bool

    Check if this ObjectId is the zero (null) object id.

    ObjectId::is_zero_hex

    fn ObjectId::is_zero_hex(hex : String) -> Bool

    Check if a hex string represents the zero (null) object id.

    ObjectId::new

    fn ObjectId::new(bytes : FixedArray[Byte]) -> ObjectId

    ObjectId::to_bytes

    fn ObjectId::to_bytes(self : ObjectId) -> Bytes

    Convert ObjectId to Bytes - zero-copy when possible

    ObjectId::to_hex

    fn ObjectId::to_hex(self : ObjectId) -> String

    ObjectId::zero

    fn ObjectId::zero(algo? : HashAlgorithm) -> ObjectId

    ObjectType

    pub(all) enum ObjectType {
    Blob
    Tree
    Commit
    Tag
    } derive(Eq,
    Debug
    )

    Git object types
    impl Show for ObjectType

    ObjectType::to_packfile_type

    fn ObjectType::to_packfile_type(self : ObjectType) -> Int

    ObjectType::to_string

    fn ObjectType::to_string(self : ObjectType) -> String

    PackCompression

    pub(all) enum PackCompression {
    Default
    Stored
    }

    Compression mode for packfile entries

    PackDeltaMode

    pub(all) enum PackDeltaMode {
    NoDelta
    RefDelta
    OfsDelta
    }

    Delta encoding mode for packfile generation

    PackObject

    pub struct PackObject {
    obj_type : ObjectType
    data : Bytes
    id : ObjectId
    offset : Int
    crc32 : UInt
    }

    A Git object ready for packing

    PackObject::new

    fn PackObject::new(obj_type : ObjectType, data : Bytes) -> PackObject

    PackObject::with_metadata

    fn PackObject::with_metadata(obj_type : ObjectType, data : Bytes, id : ObjectId, offset : Int, crc32 : UInt) -> PackObject

    Sha1State

    pub struct Sha1State {
    inner :
    Sha1State

    }

    Sha1State::finish

    fn Sha1State::finish(self : Sha1State) -> ObjectId

    Sha1State::new

    fn Sha1State::new() -> Sha1State

    Sha1State::reset

    fn Sha1State::reset(self : Sha1State) -> Unit

    Sha1State::update

    fn Sha1State::update(self : Sha1State, data : Bytes) -> Unit

    Sha1State::update_byte

    fn Sha1State::update_byte(self : Sha1State, b : Byte) -> Unit

    Sha1State::update_slice

    fn Sha1State::update_slice(self : Sha1State, data : Bytes, offset : Int, len : Int) -> Unit

    Sha1State::update_string

    fn Sha1State::update_string(self : Sha1State, s : String) -> Unit

    Sha256State

    pub struct Sha256State {
    inner :
    Sha256State

    }

    Sha256State::finish

    fn Sha256State::finish(self : Sha256State) -> ObjectId

    Sha256State::new

    Sha256State::reset

    fn Sha256State::reset(self : Sha256State) -> Unit

    Sha256State::update

    fn Sha256State::update(self : Sha256State, data : Bytes) -> Unit

    Sha256State::update_byte

    fn Sha256State::update_byte(self : Sha256State, b : Byte) -> Unit

    Sha256State::update_slice

    fn Sha256State::update_slice(self : Sha256State, data : Bytes, offset : Int, len : Int) -> Unit

    Sha256State::update_string

    fn Sha256State::update_string(self : Sha256State, s : String) -> Unit

    TreeEntry

    pub struct TreeEntry {
    mode : String
    name : String
    id : ObjectId
    }

    Tree entry in a Git tree object

    TreeEntry::new

    fn TreeEntry::new(mode : String, name : String, id : ObjectId) -> TreeEntry

    array_to_bytes

    fn array_to_bytes(arr : Array[Byte]) -> Bytes

    Helper to convert Array[Byte] to Bytes

    create_blob

    fn create_blob(content : Bytes) -> (ObjectId, Bytes)

    Create a blob object from content

    create_blob_string

    fn create_blob_string(content : String) -> (ObjectId, Bytes)

    Create a blob from string content

    create_commit

    fn create_commit(commit : Commit) -> (ObjectId, Bytes)

    Create a commit object

    create_commit_with_algo

    fn create_commit_with_algo(algo : HashAlgorithm, commit : Commit) -> (ObjectId, Bytes)

    create_object

    fn create_object(obj_type : ObjectType, content : Bytes) -> (ObjectId, Bytes)

    Create a Git object and return its ID and compressed data Format: {type} {size}\0{content} -> SHA-1 -> zlib compress

    create_object_with_algo

    fn create_object_with_algo(algo : HashAlgorithm, obj_type : ObjectType, content : Bytes) -> (ObjectId, Bytes)

    Create a git object (hash + compress) using the specified algorithm.

    create_tree

    fn create_tree(entries : Array[TreeEntry]) -> (ObjectId, Bytes)

    Create a tree object from entries Entries must be sorted by name

    create_tree_with_algo

    fn create_tree_with_algo(algo : HashAlgorithm, entries : Array[TreeEntry]) -> (ObjectId, Bytes)

    hash_array_prefix

    fn hash_array_prefix(data : Array[Byte], len : Int, hash_size? : Int) -> ObjectId

    Hash Array prefix (first len bytes), dispatching by hash_size.

    hash_blob

    fn hash_blob(content : Bytes) -> ObjectId

    Hash a blob without creating the compressed object - optimized with incremental SHA1

    hash_blob_string

    fn hash_blob_string(content : String) -> ObjectId

    Hash a blob from string - optimized with incremental SHA1

    hash_object_content

    fn hash_object_content(obj_type : ObjectType, content : Bytes) -> ObjectId

    Hash object content (without compression) - optimized with incremental SHA1

    hash_object_content_with_algo

    fn hash_object_content_with_algo(algo : HashAlgorithm, obj_type : ObjectType, content : Bytes) -> ObjectId

    Hash object content using the specified algorithm.

    hash_prefix

    fn hash_prefix(data : Bytes, len : Int, hash_size? : Int) -> ObjectId

    Hash data prefix (first len bytes), dispatching by hash_size.

    serialize_commit_content

    fn serialize_commit_content(commit : Commit) -> Bytes

    Serialize commit to raw content bytes (without git object header)

    serialize_tree

    fn serialize_tree(entries : Array[TreeEntry]) -> Bytes

    Serialize tree entries to raw content bytes (without git object header)

    sha1

    fn sha1(data : Bytes) -> ObjectId

    Compute SHA-1 hash of data

    sha1_array

    fn sha1_array(data : Array[Byte]) -> ObjectId

    Compute SHA-1 hash of data from Array

    sha1_array_prefix

    fn sha1_array_prefix(data : Array[Byte], len : Int) -> ObjectId

    Compute SHA-1 hash of Array prefix (first len bytes).

    sha1_prefix

    fn sha1_prefix(data : Bytes, len : Int) -> ObjectId

    Compute SHA-1 hash of data prefix (first len bytes).

    sha256

    fn sha256(data : Bytes) -> ObjectId

    sha256_array

    fn sha256_array(data : Array[Byte]) -> ObjectId

    sha256_array_prefix

    fn sha256_array_prefix(data : Array[Byte], len : Int) -> ObjectId

    sha256_prefix

    fn sha256_prefix(data : Bytes, len : Int) -> ObjectId

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io