Skip to main content

Crate use_git_oid

Crate use_git_oid 

Source
Expand description

§use-git-oid

Primitive Git object identifier vocabulary for RustUse.

use-git-oid validates object identifier text and models SHA-1 and future-friendly SHA-256 shapes. It does not hash content, read object storage, or resolve objects.

§Basic usage

use use_git_oid::{GitOid, GitOidKind, ShortGitOid};

let oid = GitOid::new("0123456789abcdef0123456789abcdef01234567").expect("valid oid");
let short = ShortGitOid::new("0123456").expect("valid short oid");

assert_eq!(oid.kind(), GitOidKind::Sha1);
assert_eq!(short.as_str(), "0123456");

§Scope

  • Validate hexadecimal identifier text.
  • Distinguish full and short object identifier shapes.
  • Keep hashing and object lookup out of scope.

Structs§

GitOid
A full Git object identifier.
ShortGitOid
A short object identifier prefix.

Enums§

GitOidKind
Supported Git object identifier text shapes.
GitOidParseError
Error returned while parsing object identifier text.